Skip to content

Simplify build-trace gate; remove dynamic subcommand probe#3709

Draft
eseidel wants to merge 2 commits into
mainfrom
es/fix-build-trace-gate
Draft

Simplify build-trace gate; remove dynamic subcommand probe#3709
eseidel wants to merge 2 commits into
mainfrom
es/fix-build-trace-gate

Conversation

@eseidel
Copy link
Copy Markdown
Contributor

@eseidel eseidel commented Apr 21, 2026

Two changes, stacked:

1. fix(cli): gate build tracing off for unknown Flutter versions

prepareBuildTrace used flutterVersion ?? minVersion to handle revisions that aren't on any flutter_release/* branch (dev pins). That fallback is wrong for a feature-enable check: a Shorebird-fork dev revision predating the tracing PR would be treated as new enough, get --shorebird-trace forwarded to flutter, and fail argparse hard.

Flip FlutterSupportConstraint.isSatisfiedBy to accept Version? and require either a real version ≥ the floor or an allowlisted revision to satisfy it. Unknown + non-allowlisted now leaves the trace session off. Added c2c56ab2d5483bdf86152725342f55ca6faed946 (the current pin) to the allowlist — previously it was carried implicitly by #3708's runtime probe, which this PR also removes.

2. Revert "fix: only pass --shorebird-trace to build commands that support it (#3708)"

#3708 probed each flutter build <cmd> -h at runtime to decide whether to pass --shorebird-trace. That was a belt-and-suspenders guard around two real bugs:

  1. The gate mis-classified unresolved versions (fixed by the previous commit).
  2. flutter build aar / ios-framework / linux / macos / windows didn't register the option (fixed by the companion Extend --shorebird-trace to aar, ios-framework, and desktop builds flutter#136).

With both fixes in place, every subcommand this CLI invokes accepts the flag when the gate admits tracing, and every subcommand refuses it when the gate rejects tracing — so the per-subcommand runtime probe (plus its 8 per-command call-site detours and its help-output cache) is dead weight.

Landing order

This PR must land after shorebirdtech/flutter#136 is merged AND bin/internal/flutter.version is bumped to a revision that includes it. I reproduced a hard crash on shorebird release macos when this simplification is applied without the Flutter side (see Scenario C counter-factual below).

Test plan

  • dart test packages/shorebird_cli/test/src/artifact_builder/artifact_builder_test.dart — 92 tests pass.

End-to-end on a fresh test project (/tmp/shorebird-trace-test/demo):

  • Scenario A — Shorebird gate fix (alone). shorebird release android --dry-run --flutter-version be0b343f (a pre-trace Shorebird-fork dev hash, not on any flutter_release/* branch).
    • With both fixes: Command: flutter build appbundle --release --target-platform=android-arm,android-arm64,android-x64 — no --shorebird-trace.
    • Counter-factual, pre-fix baseline (git checkout 2d0f8919~1, same command): Could not find an option named "--shorebird-trace". Command: flutter build appbundle ... --shorebird-trace=/…/build-trace-android.json.
  • Scenario B — current pin baseline. shorebird release android --dry-run (pin is allowlisted): builds AAB end-to-end, writes build/shorebird/debug/build-trace-android.json (17.8KB of valid Chrome Trace Event Format JSON).
  • Scenario C — desktop. shorebird release macos --dry-run:
    • Counter-factual, this PR applied without the Flutter side: Could not find an option named "--shorebird-trace". Command: flutter build macos --release --shorebird-trace=…. This is the crash that motivates the landing-order note.
    • With the Flutter pin bumped to the companion PR's branch HEAD + that hash allowlisted: ✓ Built build/macos/Build/Products/Release/demo.app (48.6MB) / No issues detected.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 21, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@eseidel eseidel marked this pull request as draft April 21, 2026 22:06
eseidel added 2 commits April 21, 2026 15:16
`prepareBuildTrace` used `flutterVersion ?? minVersion` to handle
revisions that aren't on any `flutter_release/*` branch (dev pins).
That fallback is wrong for a feature-enable check: a Shorebird-fork
dev revision predating the tracing PR would be treated as new enough,
get `--shorebird-trace` forwarded to flutter, and fail argparse hard.

Flip `FlutterSupportConstraint.isSatisfiedBy` to accept `Version?` and
require an actual version above the floor (or an allowlisted revision)
to satisfy it. Unknown version + non-allowlisted revision now leaves
the trace session off.

The current pin remains covered via the allowlist.
…rt it (#3708)"

This reverts commit 2d0f891.

#3708 probed each `flutter build <cmd> -h` at runtime to decide whether
to pass `--shorebird-trace`. That was a belt-and-suspenders guard around
two real bugs:

1. The Shorebird gate mis-classified unresolved Flutter versions (dev
   revisions not on any `flutter_release/*` branch) as new enough, so
   it opted pre-feature pins into tracing.
2. `flutter build aar` / `ios-framework` / `linux` / `macos` /
   `windows` didn't register the option, so the flag couldn't be
   forwarded to them safely.

The previous commit on this branch fixes (1). The companion
shorebirdtech/flutter#136 fixes (2) and must be on the Shorebird
Flutter pin before this lands. With both in place, every subcommand
this CLI invokes accepts the flag when the gate admits tracing, and
every subcommand refuses it when the gate rejects tracing — so the
per-subcommand runtime probe (plus its 8 per-command call-site
detours and its help-output cache) is dead weight.
@eseidel eseidel force-pushed the es/fix-build-trace-gate branch from 6709633 to 838924a Compare April 21, 2026 22:18
@eseidel eseidel changed the title fix(cli): gate build tracing off for unknown Flutter versions Simplify build-trace gate; remove dynamic subcommand probe Apr 21, 2026
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