fix(bazelrc): make undefined-config error self-explanatory#1131
Draft
gregmagolan wants to merge 1 commit into
Draft
fix(bazelrc): make undefined-config error self-explanatory#1131gregmagolan wants to merge 1 commit into
gregmagolan wants to merge 1 commit into
Conversation
✨ Aspect Workflows Tasks📅 Mon May 25 22:38:13 UTC 2026
|
a6593b0 to
cc84d55
Compare
b8488e6 to
a13ddd0
Compare
thesayyn
reviewed
May 25, 2026
| // `lib/lifecycle.axl::announce`. Color setup mirrors the helper | ||
| // so the verdict glyph and labels match. | ||
| let color = std::io::stderr().is_terminal() || on_recognized_ci(); | ||
| let color = crate::term::color_enabled(); |
Member
There was a problem hiding this comment.
its sort of sad that CI specific code is creeping into the rust code. ideally, this should be knob on the parse_bazelrc call.
a13ddd0 to
f10670e
Compare
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.
Before
After
(rendered with ANSI colors on a TTY/CI; bold sections + red
bazelrc:not shown in the markdown below)Bazel itself has hard-errored on undefined
--config=since 0.16.0; bazel#7116 (request for a tolerant mode) is closed won't-fix.The
undefined config 'ci' for command 'test'error rendered with no further context, fired late in the task lifecycle (aftertask_startedhad already created CI status checks and authenticated with GitHub), and the wrapping AXL traceback made it read like an internal Aspect crash rather than a bazelrc resolution issue users could fix themselves.Five coordinated fixes:
1. Validate bazelrc before lifecycle hooks. Flag aggregation,
parse_rc, andexpand_allnow run beforesetup_phase/task_startedin bazel_runner.axl. An rc-resolution error fails with no CI side effects — no status checks created, no API calls burned.2. Enrich the error message. The block leads with a
bazelrc:prefix, surfaces the Bazel workspace root (so sub-workspace anchor mismatches are visible — parentconfig.axlsets--config=ciwhile the inner.bazelrcdoesn't define:ci), lists the loaded rc files, and inlines the--announce-rcview for the failing command. For rc-file references it also names the file that owns the unresolved--config=Xline.3. ANSI colors + bold headers. Matching the SGR conventions used in
axl-runtime/src/eval/multi_phase.rs: bold red for thebazelrc:prefix, bold for section headers, dim for the subsystem-intro line. Color detection lives in the newaxl-runtime::termmodule — single source of truth for the AXL runtime, the task lifecycle headers, and the bazelrc error block. Honors the NO_COLOR convention (disable iff present and non-empty); AXL-sidelib/environment.axl::color_enableddoes the same.4. Strip the AXL traceback. The error is propagated through anyhow without losing its
BazelRcErrortype;EvalError's Display renders pre-shaped user errors viastarlark::Error::without_diagnostic()andmain.rsswitches from{err:?}to{err}whenEvalError::is_pre_shaped_user_error()returns true. Non-bazelrc errors keep the full Starlark diagnostic so AXL/Aspect authors can debug.5. Workspace-relative paths in
announce(). In-tree rc files render as./bazel/defaults.bazelrc; external files (e.g.~/.bazelrc) keep their absolute path.Changes are visible to end-users: yes
Suggested release notes
undefined config '<name>' for command '<cmd>'error fromaspect build/aspect testnow fails before any lifecycle hooks fire (no stuck CI status check, no wasted API calls) and expands into a Bazel-style colored explanation: the Bazel workspace root, the loaded.bazelrcfiles with their workspace-relative or absolute paths, an inline--announce-rcview, and suggested fixes. The AXL traceback is stripped for these errors. ANSI colors honor the NO_COLOR convention. Sub-workspace anchor mismatches (parentconfig.axlsetting--config=ciwhile the inner workspace's.bazelrcdoesn't define:ci) are now diagnosable at a glance.Test plan
--announce-rcdump and./workspace-relative paths), rc-file source attribution via theUnresolved --config=X reference in:block, transitive expansion source attribution, the(none)rendering under--ignore_all_rc_files, a regression guard against internal jargon (injection,BazelTrait,extra_flags), ANSI escape embedding underwith_ansi_errors(true),loaded_rc_files()filtering out the synthetic CLI source, andannounce()rendering in-tree vs out-of-tree paths.NO_COLORnon-empty disables even on CI;NO_COLOR=""(empty) is treated as unset per the spec; no-CI-and-no-TTY means no color; each recognized CI env var triggers detection. Uses an RAIIEnvGuardto snapshot/clear/restore process env around each case, serialized via a Mutex against cargo's parallel runner..aspect/config.axlsetting--config=ciand a sub-workspace withMODULE.bazelbut no.bazelrc. Confirmed only→ 🎬 Running test taskprints before the error, the bazelrc block renders in color on a TTY (and plain underNO_COLOR=1), and no AXL traceback wraps the message.Follow-ups (separate PRs)
skip_config_if_missingfromBazelTrait.extra_flagsso framework-set configs become "soft" by design — the right primary fix for the sub-workspace case. This PR improves the error for cases where strict behavior remains correct.