Skip to content

fix(cli): bar a stale BEX_WORKSPACE name from direct-ID fallback searches - #240

Merged
puncsky merged 2 commits into
mainfrom
bex-agent/ags-dc39b08uqmis73a84l30
Nov 25, 2026
Merged

puncsky merged 2 commits into
mainfrom
bex-agent/ags-dc39b08uqmis73a84l30

Conversation

@bex-co

@bex-co bex-co Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Direct-ID CLI commands (pg get, kv get, services delete/update, …) proceed past startup when BEX_WORKSPACE no longer resolves, but a missed typed id falls back to a workspace-scoped name search that sends the raw name as ownerId — the exact leak w32/117 just closed on the found path. The control-plane transport now bars the unresolvable name from ownerId/owner path segments and fails fast in the words of the startup refusal. Found paths send no workspace value and are unaffected.

Changes

  • lego/cli/internal/bridge/workspace.go: ResolveWorkspaceName records the unresolvable name (blockedOwner) when a direct-ID command proceeds past a failed lookup; clarified the WorkspaceIfResolvable doc.
  • lego/cli/internal/bridge/transport.go: controlPlaneTransport refuses (local 400) any control-plane request carrying the barred name, via carriesBlockedOwner + blockedOwnerRefusal.
  • Tests: TestStaleWorkspaceNameNeverLeaksOnDirectIDMiss (end-to-end: 4 refusal cells + 5 clean-miss cells, zero-leak oracle) and TestBlockedOwnerRefusesTheBarredName / TestBlockedOwnerRefusalNamesTheWorkspace (bridge unit tests).
  • .claude/skills/rt-fix-logic-bugs/ledger.md: recorded the fix and the audited-holds cells (cap: dropped the two oldest Skipped).

Testing

  • New e2e test RED before the fix (ownerId=stale-ws observed on postgres, key-value, services fallbacks), GREEN after.
  • TestStaleWorkspaceNameBlocksOnlyConsumers (existing found-path matrix) still passes; full internal/bridge suite passes.
  • bash scripts/rt-pre-pr-check.sh origin/main: OK.
  • CI is the full gate.

🤖 Opened by a bex agent session (muse) · view session

bex agent and others added 2 commits November 25, 2026 08:17
…ches

A direct-ID command with an unresolvable BEX_WORKSPACE proceeds past
startup resolution, but a missed typed id falls back to a
workspace-scoped name search (ListServices/ListPostgres/ListKeyValue with
ownerId), sending the raw name as ownerId on the 404 path. The
control-plane transport now refuses requests carrying the barred name
and fails fast in the words of the startup refusal; found paths send no
workspace value and are unaffected.

Pinned by TestStaleWorkspaceNameNeverLeaksOnDirectIDMiss and
TestBlockedOwnerRefusesTheBarredName.
…fusal reason, and omit barred X-Bex-Workspace
@puncsky

puncsky commented Nov 25, 2026

Copy link
Copy Markdown
Member

Pushed a small follow-up refinement before merging:

  1. Avoid path-segment collisions in carriesBlockedOwner: previously checked every path segment (seg == barred), which would falsely block valid direct-ID requests like GET /v1/services/{id} when BEX_WORKSPACE happened to be named "services", "postgres", or "v1". Narrowed path matching to /owners/{barred} while keeping the ownerId query parameter check.
  2. Preserve the actual startup refusal reason: stored blockedOwnerInfo{name, reason} with err.Error() so an ambiguous workspace name (several workspaces are named ...) isn't misreported as no workspace named.
  3. Omit barred name from X-Bex-Workspace: on /v1/services/... requests, skip setting X-Bex-Workspace when the selected value equals the barred unresolved name.

Verified with go test ./internal/bridge/ . (including TestStaleWorkspaceName*), go vet, gofmt, and rt-pre-pr-check.sh, and marked the PR ready for merge once CI finishes.

@puncsky
puncsky marked this pull request as ready for review November 25, 2026 09:24
@puncsky
puncsky merged commit 5125816 into main Nov 25, 2026
11 checks passed
@puncsky
puncsky deleted the bex-agent/ags-dc39b08uqmis73a84l30 branch November 25, 2026 09:42
@github-actions github-actions Bot mentioned this pull request Nov 30, 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.

1 participant