Fix wt-metadata-refresh failing on .bazelproject with commented directories#64
Merged
guodong-sq merged 1 commit intoblock:mainfrom Apr 15, 2026
Merged
Conversation
…tories Two bugs caused metadata refresh to always fail: 1. The awk regex for parsing .bazelproject commented lines (e.g. ' # ca') didn't actually filter them out — [^#] matched the second space char, so invalid paths like '//# ca/...' leaked into the bazel query. 2. set -o pipefail + piping bazel query into sort meant any non-zero exit from bazel query (e.g. 'no targets found beneath .hooks') killed the whole pipeline before the exit code could be captured. Fix: strip whitespace first then check for '#' prefix, use --keep_going to tolerate missing targets, and || true to avoid pipefail issues. Co-authored-by: Amp <amp@ampcode.com> Amp-Thread-ID: https://ampcode.com/threads/T-019d8e51-8b94-7615-a478-c7aa9b77f49c
21142b1 to
7dd25dd
Compare
guodong-sq
approved these changes
Apr 15, 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.
Why
wt-metadata-refreshalways fails when the.bazelprojectfile contains commented-out directories (e.g.# ca,# deposits).What
[^#]matched the second space character instead of the#, leaking invalid paths like//# ca/...into the bazel query--keep_goingand|| trueso directories without BUILD files (e.g..github,.hooks) don't kill the entire query viapipefailRisk Assessment
Low — only affects the metadata refresh script, no production services.
Testing
Discovery: Running
wt-metadata-refreshfailed withBazel query failed for base (exit code: 2). The stderr was suppressed (2>/dev/null), so the root cause wasn't visible.Root cause analysis:
Ran the awk parser in isolation and found commented lines like
# cawere passing through:The regex
[[:space:]]+only consumed one space, then[^#]matched the second space — not the#.Confirmed the generated query included invalid paths like
//# ca/..., causing bazel query to fail entirely.After fixing the awk regex, bazel query still failed because
.githuband.hookshave no BUILD files:Validation: After both fixes, ran
wt-metadata-refreshsuccessfully — refreshed 14,949 targets and re-exported 53 metadata directories to the vault.Generated with Amp