fix(scan): warn when Maven/NuGet discovery is gated off - #161
fix(scan): warn when Maven/NuGet discovery is gated off#161Mikola Lysenko (mikolalysenko) wants to merge 1 commit into
Conversation
`scan --mode vendored`/`hosted` discovers packages through `crawl_all_ecosystems`, which silently skips Maven/NuGet when `SOCKET_EXPERIMENTAL_MAVEN` / `SOCKET_EXPERIMENTAL_NUGET` is off. The existing `warn_maven_disabled` / `warn_nuget_disabled` warnings only fire on the partitioned-apply path, so a Maven/NuGet project scanned in vendored/hosted mode with the flag off reported `scannedPackages: 0` and success with zero explanation. Add discovery-path warnings that fire once per run, only when a Maven/NuGet project is actually present on disk (reusing the crawler's own `get_maven_repo_paths` / `get_nuget_package_paths` discovery so the signal matches exactly what an opted-in scan would crawl). The gate itself is unchanged — Maven/NuGet remain opt-in; only the silent skip is surfaced. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
Bugbot Autofix is ON. A cloud agent has been kicked off to fix the reported issue.
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit e20edca. Configure here.
| .await | ||
| .unwrap_or_default() | ||
| .is_empty() | ||
| } |
There was a problem hiding this comment.
False warnings on global scans
Medium Severity
maven_discovery_gated_off and nuget_discovery_gated_off treat any non-empty get_maven_repo_paths / get_nuget_package_paths result as a project skip. In --global / --global-prefix mode those helpers return a cache path with no project marker check (global_prefix even skips is_dir), so ordinary global scans warn about a Maven/NuGet project that was never detected.
Additional Locations (2)
Reviewed by Cursor Bugbot for commit e20edca. Configure here.


Problem
scan --mode vendored/--mode hosteddiscovers installed packages throughcrawl_all_ecosystems(crates/socket-patch-cli/src/ecosystem_dispatch.rs). That function gates Maven and NuGet behind theSOCKET_EXPERIMENTAL_MAVEN/SOCKET_EXPERIMENTAL_NUGETruntime flags and, when the flag is off, skips them silently (old lines 452-461).The user-facing
warn_maven_disabled/warn_nuget_disabledwarnings only fire on the partitioned-apply path indispatch_find— NOT on this crawl/discovery gate. So a Mavenpom.xmlproject (or a .NET project) scanned in vendored/hosted mode with the flag off exits 0 with"scannedPackages": 0and zero Maven/NuGet-related stderr. Confirmed against real prod: same command withSOCKET_EXPERIMENTAL_MAVEN=1reportsscannedPackages: 173(NuGet 0 vs 1). The docs call the vendored/hosted wiring "ungated", but it is unreachable because discovery is gated, and the user gets no signal.Fix
In
crawl_all_ecosystems(crates/socket-patch-cli/src/ecosystem_dispatch.rs:466-482), when the experimental flag is off, check whether the crawler would have found sources and, if so, emit a one-time warning:maven_discovery_gated_off/nuget_discovery_gated_off(ecosystem_dispatch.rs:64-96) — true only when the runtime flag is OFF and the crawler's ownget_maven_repo_paths/get_nuget_package_pathsreturns a non-empty set. Reusing the crawler's discovery means the signal matches exactly what an opted-in scan would crawl, and it never fires on non-Maven/non-.NET projects (guards against noise; fires at most once per run).warn_maven_discovery_gated/warn_nuget_discovery_gated(ecosystem_dispatch.rs:37-46/66-75) — discovery-path wording namingSOCKET_EXPERIMENTAL_MAVEN=1/SOCKET_EXPERIMENTAL_NUGET=1.The gate itself is unchanged — Maven/NuGet remain opt-in and are NOT enabled by default; only the previously-silent skip is surfaced. No
crawl_all_ecosystemssignature change, so no churn at the scan/get call sites.Test
Four hermetic unit tests in
ecosystem_dispatch::tests(crates/socket-patch-cli/src/ecosystem_dispatch.rs), matching the neighboringcrawl_all_gates_*gate tests (same#[serial_test::serial(experimental_gate_env)]group):maven_discovery_gated_off_warns_for_pom_project_when_flag_off— apom.xmlproject + existing local repo: gated (warns) with the flag off, NOT gated (crawled) with the flag on.maven_discovery_not_gated_without_java_project— no marker: never warns (noise guard).nuget_discovery_gated_off_warns_for_dotnet_project_when_flag_off—.csproj+ existing cache: same flag on/off assertions.nuget_discovery_not_gated_without_dotnet_project— noise guard.cargo test -p socket-patch-cli --lib ecosystem_dispatch::tests→ 37 passed, 0 failed.cargo build -p socket-patch-cliclean.Scope
Touches only
crates/socket-patch-cli/src/ecosystem_dispatch.rs. No cross-dependencies with other in-flight fixes. Warning goes to stderr, so JSON on stdout is unaffected. Note:crawl_all_ecosystemshas nosilentparam, so the one-time stderr warning is emitted regardless of--silent/--json; kept out of scope to avoid a signature change touchingscan/getcall sites.🤖 Generated with Claude Code
Note
Low Risk
User-visible stderr messaging only; experimental crawl gates and JSON stdout are unchanged aside from possible warning text on stderr.
Overview
Vendored/hosted scans no longer skip Maven and NuGet discovery silently when
SOCKET_EXPERIMENTAL_MAVEN/SOCKET_EXPERIMENTAL_NUGETare unset. Apply-time warnings only run on the partitioned-apply path;crawl_all_ecosystemsused to omit those ecosystems with no stderr, so users could seescannedPackages: 0with no explanation.When the experimental flag is off,
crawl_all_ecosystemsnow checks whether the Maven/NuGet crawlers would have found sources (via the sameget_maven_repo_paths/get_nuget_package_pathsdiscovery used for an opted-in crawl). If so, it prints a one-time stderr warning naming the env var to enable discovery. Gating behavior is unchanged — Maven/NuGet are still not crawled without opt-in.Four hermetic tests cover flag on/off and “no project marker” cases so warnings fire only when something was actually skipped.
Reviewed by Cursor Bugbot for commit e20edca. Configure here.