Skip to content

fix(router): remove AdminAuth from test-token — unblocks E2E CI bootstrap - #708

Merged
HongmingWang-Rabbit merged 1 commit into
mainfrom
fix/e2e-test-token-bootstrap
Apr 17, 2026
Merged

fix(router): remove AdminAuth from test-token — unblocks E2E CI bootstrap#708
HongmingWang-Rabbit merged 1 commit into
mainfrom
fix/e2e-test-token-bootstrap

Conversation

@HongmingWang-Rabbit

Copy link
Copy Markdown
Contributor

Summary

Reverts the AdminAuth gate on GET /admin/workspaces/:id/test-token that #612 added. This endpoint is the bootstrap path for E2E tests and fresh installs to obtain their first admin bearer token. With AdminAuth, it's a chicken-and-egg deadlock:

1. POST /workspaces (fail-open, no tokens) → creates workspace → token inserted in DB
2. AdminAuth now sees a live token → requires auth on ALL routes
3. E2E calls test-token to get first bearer → 401 "admin auth required"
4. All subsequent tests fail

The handler's own guard (TestTokensEnabled() == false when MOLECULE_ENV=prod) is the correct production gate. AdminAuth was defence-in-depth that broke the only bootstrap path.

Impact

This has been blocking ALL open PR CI for 6+ maintenance cycles. Combined with the migration 028 FK bug (fixed in #670), these two issues explain why the team's PRs have been stuck despite active development.

Timeline of CI blockers this session:

  1. Migration 028 TEXT→UUID FK — fixed by fix(migrations): TEXT→UUID in 028_workspace_artifacts — unblocks all E2E CI #670 (merged ~10:17 UTC)
  2. This bugfix(security): gate test-token endpoint behind AdminAuth #612's AdminAuth on test-token (introduced ~21:15 UTC yesterday, masked by the migration failure until fix(migrations): TEXT→UUID in 028_workspace_artifacts — unblocks all E2E CI #670 landed)

Test plan

🤖 Generated with Claude Code

#612 added AdminAuth to GET /admin/workspaces/:id/test-token, breaking
the chicken-and-egg bootstrap that E2E tests rely on:

1. POST /workspaces creates first workspace (fail-open, no tokens)
2. Provision generates a workspace auth token → inserts into DB
3. AdminAuth now sees a live token → requires auth on ALL routes
4. E2E calls test-token to get its first admin bearer → 401
5. All subsequent E2E calls fail → EVERY open PR CI blocked

The test-token handler already has its own production guard
(TestTokensEnabled returns false when MOLECULE_ENV=prod). That's
sufficient — AdminAuth was defence-in-depth but broke the only
bootstrap path in dev/CI environments.

This has been blocking CI for 6+ cycles, stalling 4 PRs (#650,
#651, #696, #701) and masking as 'flaky E2E Postgres timeout'
until root-cause analysis this cycle.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@HongmingWang-Rabbit
HongmingWang-Rabbit merged commit bd09c58 into main Apr 17, 2026
6 checks passed
@HongmingWang-Rabbit
HongmingWang-Rabbit deleted the fix/e2e-test-token-bootstrap branch April 17, 2026 12:17
molecule-ai Bot pushed a commit that referenced this pull request Apr 21, 2026
fix(router): remove AdminAuth from test-token — unblocks E2E CI bootstrap
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