Skip to content

Check bazel_args with Bazel's own flag parser - #37

Merged
anakanemison merged 1 commit into
mainfrom
mschaller/u02-validate-bazel-args
Nov 9, 2026
Merged

anakanemison merged 1 commit into
mainfrom
mschaller/u02-validate-bazel-args

Conversation

@anakanemison

@anakanemison anakanemison commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

bazel_args is spliced into bazel aquery, but nothing checked that it holds flags. SKILL.md now says it holds flags, with one right and one wrong example, and runs bazel canonicalize-flags --for_command=aquery on it just before aquery, from a one-liner that hands the list to Bazel as argv, so no value is split on spaces. Bazel refuses a command, a target pattern or a stray word after a boolean flag (--keep_going true), and prints the accepted flags in canonical form.

A QGIS migration in any2bazel-lab recorded a whole bazel aquery ... command as bazel_args; the migration looked converged, while the lab's script that spliced the field into bazel aquery failed and produced no parity result. Checked against Bazel 9.3.1. This version has not been through a migration run.

Stacked on main (tracking issue: #35). pytest tests/: 132 passed (132 on main). Lab proposal: P22.

🤖 Generated with Claude Code

@anakanemison
anakanemison added this pull request to stack #59 October 20, 2026 18:10
Base automatically changed from mschaller/u01-configure-file-case-insensitive to main October 26, 2026 13:30
@anakanemison
anakanemison force-pushed the mschaller/u02-validate-bazel-args branch from 27bf8be to 4f689d1 Compare October 26, 2026 13:30
Comment thread scripts/config.py Outdated
return name in self.exclude_targets


def validate_bazel_args(args) -> tuple:

@armandomontanez armandomontanez Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just use Bazel's canonicalize-flags for this. IIRC it chokes when you enter a target pattern (for better or for worse).

Otherwise, we need to properly handle boolean flags which don't accept --keep_going true, which can mask problems like --keep_going //some/target:pattern

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, implemented.

bazel_args is meant for the flags that make aquery mirror the real build
(--config=release, -c opt). Anything that consumes it splices it into a
bazel command line, but nothing checked its shape, and the SKILL.md text
sits next to a literal `bazel aquery ...` line that is easy to paste in.

Measured in any2bazel-lab: on a QGIS migration the agent recorded the whole
aquery command as bazel_args. Its own diff never read the field, so the
migration looked converged, while a consumer that spliced the field into
`bazel aquery` failed on a second query expression and produced no parity
result.

SKILL.md now says the field holds flags, with one right and one wrong
example, and runs `bazel canonicalize-flags --for_command=aquery` on it
just before aquery. Bazel refuses anything that is not an aquery option,
including a target pattern and a stray word after a boolean flag
(`--keep_going true`), which a hand-written check would have to
special-case. The one-liner hands the list to Bazel as argv (os.execvp),
so a value with a space in it is not split. It does not check that a
--config exists; aquery fails on one that does not.

Checked against Bazel 9.3.1: it refused a whole aquery command and
`--keep_going true`, and accepted `--copt=-DMSG="a b"`, `-c opt`,
`--config=release` and a config with no bazel_args. The lab's later QGIS
run, made with an earlier version of this change (a Python check),
recorded only valid flags; this version has not been through a migration
run.

Lab-Proposal: P22
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@anakanemison
anakanemison removed this pull request from stack #59 November 2, 2026 17:49
@anakanemison
anakanemison force-pushed the mschaller/u02-validate-bazel-args branch from 4f689d1 to ccf83d5 Compare November 2, 2026 17:50
@anakanemison anakanemison changed the title Validate that bazel_args holds flags, not a command Check bazel_args with Bazel's own flag parser Nov 2, 2026
@anakanemison
anakanemison added this pull request to stack #63 November 2, 2026 17:54
@anakanemison
anakanemison merged commit 79e2abf into main Nov 9, 2026
2 checks passed
@anakanemison
anakanemison deleted the mschaller/u02-validate-bazel-args branch November 9, 2026 18:45
anakanemison added a commit that referenced this pull request Nov 9, 2026
)

A Bazel target mapped through `target_map` to an excluded CMake name was
skipped by the diff but missing from `excluded.bazel`, because the
summary checked the raw label. A new helper, `_bazel_renames`, makes the
rename decision once; the diff and `excluded_summary` both use it, and
the per-side summaries later in this series are built on it.

Stacked on #37 (tracking issue: #35). `pytest tests/`: 134 passed (132
on `main`). Lab proposal: support for P17.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants