Skip to content

fix(compat): leave the BuildKit tunnel ack unset under request_body.buildkit - #444

Merged
scttbnsn merged 1 commit into
dev/v2.1from
fix/compat-buildkit-autoack
Sep 4, 2026
Merged

fix(compat): leave the BuildKit tunnel ack unset under request_body.buildkit#444
scttbnsn merged 1 commit into
dev/v2.1from
fix/compat-buildkit-autoack

Conversation

@scttbnsn

@scttbnsn scttbnsn commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

GRPC=1 or SESSION=1 auto-sets insecure_accept_opaque_buildkit_tunnels, and compat runs before validation. An operator who'd migrated to a request_body.buildkit policy but still carried GRPC=1 from their old Tecnativa environment hit a startup refusal naming a key they never wrote, because the ack and a mediation policy are mutually exclusive.

Compat now skips the auto-ack whenever request_body.buildkit is configured at the top level or on any client profile, which is exactly the condition the mutual-exclusion check refuses on. Both sides ask one shared predicate (buildkitMediationConfigured) so they can't drift. An explicitly written ack alongside a policy is still refused.

With a top-level policy this tightens the posture: the ack only ever gated startup admission, and what happens to a /session or /grpc request at runtime is decided by request_body.buildkit. So the generated tunnel rules are admitted by the mediation arm instead of the ack arm, and every gRPC message on those tunnels is checked against the policy rather than passing uninspected.

With the policy on a client profile only, startup still refuses, and should: the compat rules are top-level and apply to every client no profile matches. The refusal now says the rules came from GRPC/SESSION and names the two cures that work (unset them, or add a top-level policy), instead of pointing at a config key that isn't in the file. Origin comes from what compat actually generated, not from env presence, so a hand-written tunnel rule with GRPC=1 idle in the environment keeps the original message.

Tests for both branches. migration.mdx, configuration.mdx and security.mdx had described the old behavior and are corrected. CHANGELOG under Unreleased ### Fixed.

Changelog

  • ✨ Added shared BuildKit mediation detection across top-level configuration and client profiles.
  • 🔧 Changed GRPC=1 and SESSION=1 compatibility handling to skip automatic acknowledgment when mediation is configured.
  • 🔧 Changed validation messages for compatibility-generated rules to identify the source environment variables and valid remediation.
  • 🔧 Added provenance tracking through HasCompatGeneratedRules().
  • ⚠️ Profile-only mediation still refuses startup because compatibility-generated rules are top-level.
  • ✨ Added tests for top-level mediation, profile mediation, explicit acknowledgment, and hand-written rules.
  • 🔧 Updated configuration, migration, and security documentation.

Concerns

  • Verify that every new mediation scope is included by buildkitMediationConfigured and mutual-exclusion validation.
  • Verify that compatibility provenance is reset correctly when configuration reloads or compatibility processing runs more than once.
  • Verify that refusal guidance cannot suggest insecure_accept_opaque_buildkit_tunnels for compatibility-generated rules.

…uildkit

GRPC=1 and SESSION=1 auto-set insecure_accept_opaque_buildkit_tunnels, and
ApplyCompat runs before validation, so an operator who had already migrated
to a request_body.buildkit policy but still carried GRPC=1 from their old
Tecnativa environment hit a startup refusal naming a key they never wrote.
The acknowledgment and a mediation policy are mutually exclusive.

Compat now skips the auto-ack whenever request_body.buildkit is configured,
at the top level or on any client profile, which is exactly the condition
validateBuildkitAckMutualExclusion refuses on. Both sides ask one shared
predicate so they cannot drift. The alternative, exempting the compat-sourced
value from the exclusion check, needs provenance tracking on Config and
breaks the #185 invariant that the wholesale ack and the mediator never
stack, which other code comments already rely on.

With a top-level policy this tightens the posture rather than relaxing it.
The acknowledgment only ever gated startup admission; what happens to a
/session or /grpc request at runtime is decided by
filter.BuildkitOptions.TunnelConfigured, which comes from
request_body.buildkit. So the generated /grpc and /session rules are admitted
by validateBuildkitTunnelRulesForPolicy's buildkitConfigured arm instead of
its acknowledgment arm, and every gRPC message on those tunnels goes through
the mediator's per-method policy instead of passing uninspected.

With the policy on a client profile only, startup still refuses, and should:
that check reads the top-level request_body.buildkit, the compat rules are
top-level, and they apply to every client matching no profile, so letting a
profile's policy admit them would open an uninspected tunnel for exactly the
clients it does not cover. The skip stays scoped to any-scope rather than
narrowing to top-level-only because that gives the clearer message. Narrowing
would put the profile-only case back on the mutual-exclusion error, which
names a key the operator never wrote and tells them to set it false, when
only unsetting GRPC/SESSION or adding a top-level policy actually works; it
would also refuse the safe GET,HEAD-only shape (GRPC=1 without POST=1), which
cannot open a tunnel at all. Instead the tunnel refusal now names its origin:
when the rules under it were synthesized by compat, it says so, and gives the
two cures that work. Origin comes from what ApplyCompat actually did, not
from env presence, so a hand-written rule with GRPC=1 idle in the environment
keeps the original message and its acknowledgment cure.

An explicitly configured acknowledgment alongside request_body.buildkit is
still refused, compat never clears one, and the skip log reports the flag's
real value instead of claiming it is unset.
@scttbnsn

scttbnsn commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@vercel

vercel Bot commented Sep 4, 2026

Copy link
Copy Markdown

Deployment failed for project sockguard-website with the following error:

Resource is limited - try again in 24 hours (more than 100, code: "api-deployments-free-per-day").

Learn More: https://vercel.com/codeswhat?upgradeToPro=build-rate-limit

@coderabbitai

coderabbitai Bot commented Sep 4, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Team

Run ID: dc7be6ca-7d77-4190-a828-c41d694bfa39

📥 Commits

Reviewing files that changed from the base of the PR and between d44ca5d and 96a281c.

⛔ Files ignored due to path filters (1)
  • CHANGELOG.md is excluded by !CHANGELOG.md
📒 Files selected for processing (9)
  • app/internal/cmd/rules.go
  • app/internal/cmd/rules_buildkit_compat_ack_test.go
  • app/internal/config/compat.go
  • app/internal/config/compat_buildkit_ack_test.go
  • app/internal/config/config.go
  • app/internal/config/validate.go
  • docs/content/docs/configuration.mdx
  • docs/content/docs/migration.mdx
  • docs/content/docs/security.mdx

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

Compat mode now detects BuildKit mediation at the top level and in client profiles. It records whether rules came from Tecnativa compatibility variables and changes acknowledgement handling accordingly. Validation reports compat-generated rule origins, keeps explicit acknowledgement and mediation mutually exclusive, and distinguishes profile-only mediation from top-level mediation. Tests and documentation cover these outcomes.

Suggested labels: second-opinion

Merge Risk: ⚪ Minimal · up to 96a28

BuildKit compatibility variables now avoid adding an incompatible opaque-tunnel acknowledgement when mediation is configured, while preserving refusal for profile-only mediation that cannot cover generated top-level rules. The documented and tested behavior is ready to merge.

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/compat-buildkit-autoack

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai

coderabbitai Bot commented Sep 4, 2026

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@scttbnsn

scttbnsn commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Sep 4, 2026

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@scttbnsn

scttbnsn commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Sep 4, 2026

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@scttbnsn

scttbnsn commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Sep 4, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot added the second-opinion Summons Greptile as an independent second-opinion reviewer label Sep 4, 2026
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

@greptileai Review exact head 96a281c6b45c656608c6c9fad9b251facb361c6a. Review for correctness, security issues, and cross-file regressions.

@biggest-littlest biggest-littlest left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewed against the CHANGELOG entry and the diff; CI green outside the qlty/Vercel quota noise.

@ALARGECOMPANY ALARGECOMPANY left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewed against the CHANGELOG entry and the diff; CI green outside the qlty/Vercel quota noise.

@scttbnsn
scttbnsn merged commit b30f053 into dev/v2.1 Sep 4, 2026
63 of 65 checks passed
@scttbnsn
scttbnsn deleted the fix/compat-buildkit-autoack branch September 4, 2026 22:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

second-opinion Summons Greptile as an independent second-opinion reviewer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants