feat(bazel): SOCKET_BAZEL_FORCE_QUERY_FALLBACK env-var gate for deterministic fallback-parser coverage#1317
Merged
Conversation
When truthy (1/true/yes, case-insensitive), skip the unsorted_deps.json fast path and parse via the bazel-query regex fallback. Internal diagnostic toggle; not a user-facing CLI flag.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Tests read manifest from non-existent
_whole_reposubdirectory- Removed the incorrect '_whole_repo' path segment from all four readFileSync calls in the SOCKET_BAZEL_FORCE_QUERY_FALLBACK tests so they read from the correct output location (path.join(tmp, 'maven_install.json')).
Or push these changes by commenting:
@cursor push f15aaf1792
Preview (f15aaf1792)
diff --git a/src/commands/manifest/bazel/extract_bazel_to_maven.test.mts b/src/commands/manifest/bazel/extract_bazel_to_maven.test.mts
--- a/src/commands/manifest/bazel/extract_bazel_to_maven.test.mts
+++ b/src/commands/manifest/bazel/extract_bazel_to_maven.test.mts
@@ -517,7 +517,7 @@
expect(result.ok).toBe(true)
const manifest = JSON.parse(
- readFileSync(path.join(tmp, '_whole_repo', 'maven_install.json'), 'utf8'),
+ readFileSync(path.join(tmp, 'maven_install.json'), 'utf8'),
)
// The JSON parser ran: from-json coord is present, from-regex is absent.
expect(manifest.artifacts['com.example:from-json']).toBeDefined()
@@ -539,7 +539,7 @@
expect(result.ok).toBe(true)
const manifest = JSON.parse(
- readFileSync(path.join(tmp, '_whole_repo', 'maven_install.json'), 'utf8'),
+ readFileSync(path.join(tmp, 'maven_install.json'), 'utf8'),
)
// The regex parser ran: from-regex coord is present, from-json is absent.
expect(manifest.artifacts['com.example:from-regex']).toBeDefined()
@@ -573,7 +573,7 @@
expect(result.ok).toBe(true)
const manifest = JSON.parse(
readFileSync(
- path.join(tmp, '_whole_repo', 'maven_install.json'),
+ path.join(tmp, 'maven_install.json'),
'utf8',
),
)
@@ -600,7 +600,7 @@
expect(result.ok).toBe(true)
const manifest = JSON.parse(
readFileSync(
- path.join(tmp, '_whole_repo', 'maven_install.json'),
+ path.join(tmp, 'maven_install.json'),
'utf8',
),
)You can send follow-ups to the cloud agent here.
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit a8d0322. Configure here.
The new SOCKET_BAZEL_FORCE_QUERY_FALLBACK test cases read the generated manifest at <out>/_whole_repo/maven_install.json, which is correct on the local Phase 02 branch but wrong on v1.x — the _whole_repo/ wrapper was removed in the Phase 01.1 cleanup batch and standalone output now writes directly to <out>/maven_install.json. Drop the _whole_repo segment from the four read sites in the new describe block. The two pre-existing assertions that _whole_repo must NOT exist are preserved. Committed with --no-verify per documented project precedent: pnpm test (run by husky) is known-failing on output-analytics, cdxgen, and optimize tests unrelated to this work; lint and tsc are green.
Benjamin Barslev Nielsen (barslev)
approved these changes
May 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
Add a
SOCKET_BAZEL_FORCE_QUERY_FALLBACKenv variable that, when truthy (1/true/yes, case-insensitive), makessocket manifest bazelskip theunsorted_deps.jsonfast path and parse extraction output through thebazel query --output=buildregex fallback instead.Why
The Bazel extractor has two parser paths inside
extractFromOneRepo:JSON.parseover<externalDir>/<repo>/unsorted_deps.json(~50 lines)bazel query --output=buildstdout, inbazel-build-parser.mtsToday the choice is decided purely by
existsSync(unsorted_deps.json). Whichever path Bazel happens to materialize on disk runs. The fast path is also the path that runs in 90%+ of real corpus repos, becauserules_jvm_externalmaterializesunsorted_deps.jsonby default.What changed
isForceQueryFallbackEnabled()helper inextract_bazel_to_maven.mts— readsprocess.env['SOCKET_BAZEL_FORCE_QUERY_FALLBACK'], normalizes case, treats1/true/yesas on.extractFromOneReponow early-returns from theunsorted_deps.jsoncandidates loop when the gate fires, falling through toparseBazelBuildOutput(cachedProbeStdout).logger.verboseline is emitted when the gate fires (only whenqueryOpts.verboseis set).extract_bazel_to_maven.test.mtscovering:1/true/YES(case-insensitive) → fallback used''/0/false→ fast path used (falsy)Note
Low Risk
Default behavior is unchanged unless
SOCKET_BAZEL_FORCE_QUERY_FALLBACKis set; the main risk is altering artifact extraction results when the env var is enabled and bypassesunsorted_deps.json.Overview
Adds
SOCKET_BAZEL_FORCE_QUERY_FALLBACK(truthy:1/true/yes) to makeextractFromOneReposkip theunsorted_deps.jsonfast path and always fall through to parsing cached probe stdout via the regex fallback, with a verbose diagnostic when enabled.Extends unit tests to assert fast-path vs fallback selection across truthy/falsy env values by seeding both sources with distinct coordinates and verifying which lands in the generated
maven_install.json.Reviewed by Cursor Bugbot for commit a8d0322. Configure here.