test: make tests hermetic against CI runner env vars #2101

Closed
core-be wants to merge 2 commits from fix/staging-test-hermetic-env into staging
Member

Fixes 22 pre-existing test failures on staging caused by CI runner env var pollution (ADMIN_TOKEN + MOLECULE_ORG_ID).

  • ADMIN_TOKEN set → AdminAuth closes fail-open, requires bearer
  • MOLECULE_ORG_ID set → saasMode() true → RFC-1918 allowed in SSRF checks

Adds t.Setenv to affected tests across handlers, middleware, and router so they explicitly control the env state they depend on.

Test plan:

  • Full ./... test suite passes (37 packages, 0 failures)
Fixes 22 pre-existing test failures on staging caused by CI runner env var pollution (ADMIN_TOKEN + MOLECULE_ORG_ID). - ADMIN_TOKEN set → AdminAuth closes fail-open, requires bearer - MOLECULE_ORG_ID set → saasMode() true → RFC-1918 allowed in SSRF checks Adds t.Setenv to affected tests across handlers, middleware, and router so they explicitly control the env state they depend on. Test plan: - [ ] Full `./...` test suite passes (37 packages, 0 failures)
core-be added 1 commit 2026-06-01 14:08:32 +00:00
test: make tests hermetic against CI runner env vars
Block internal-flavored paths / Block forbidden paths (pull_request) Successful in 13s
CI / Detect changes (pull_request) Successful in 10s
CI / Shellcheck (E2E scripts) (pull_request) Successful in 1m18s
E2E API Smoke Test / detect-changes (pull_request) Successful in 17s
E2E API Smoke Test / E2E API Smoke Test (pull_request) Waiting to run
E2E Chat / detect-changes (pull_request) Successful in 20s
E2E Chat / E2E Chat (pull_request) Waiting to run
Handlers Postgres Integration / detect-changes (pull_request) Successful in 10s
Handlers Postgres Integration / Handlers Postgres Integration (pull_request) Waiting to run
Harness Replays / detect-changes (pull_request) Successful in 6s
Harness Replays / Harness Replays (pull_request) Waiting to run
lint-required-no-paths / lint-required-no-paths (pull_request) Successful in 1m28s
Runtime PR-Built Compatibility / detect-changes (pull_request) Successful in 13s
Runtime PR-Built Compatibility / PR-built wheel + import smoke (pull_request) Waiting to run
Secret scan / Scan diff for credential-shaped strings (pull_request) Successful in 7s
gate-check-v3 / gate-check (pull_request_target) Successful in 5s
qa-review / approved (pull_request_target) Successful in 13s
sop-checklist / all-items-acked (pull_request) acked: 0/7 — missing: comprehensive-testing, local-postgres-e2e, staging-smoke, +4 — body-unfilled: comprehensive-testing, local-postgres-e2
sop-checklist / na-declarations (pull_request) N/A: (none)
sop-checklist / all-items-acked (pull_request_target) Successful in 6s
security-review / approved (pull_request_target) Successful in 10s
sop-tier-check / tier-check (pull_request_target) Successful in 5s
CI / Platform (Go) (pull_request) Failing after 5m53s
CI / all-required (pull_request) Failing after 4m14s
CI / Canvas (Next.js) (pull_request) Successful in 6m44s
CI / Canvas Deploy Reminder (pull_request) Waiting to run
CI / Python Lint & Test (pull_request) Successful in 7m50s
1bc8452911
The CI runners set ADMIN_TOKEN and MOLECULE_ORG_ID in the environment.
These leak into test processes and flip security posture gates:

- ADMIN_TOKEN set → AdminAuth skip fail-open, require bearer
- MOLECULE_ORG_ID set → saasMode() true → RFC-1918 allowed in SSRF checks

Add t.Setenv to 22 affected tests across handlers, middleware, and router
so they explicitly control the env state they depend on.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
core-be added 1 commit 2026-06-01 15:29:04 +00:00
fix(lint): remove unused canvasUserMessage type
CI / Detect changes (pull_request) Successful in 23s
Block internal-flavored paths / Block forbidden paths (pull_request) Successful in 25s
E2E API Smoke Test / detect-changes (pull_request) Successful in 37s
CI / Shellcheck (E2E scripts) (pull_request) Successful in 54s
Handlers Postgres Integration / detect-changes (pull_request) Successful in 12s
E2E Chat / detect-changes (pull_request) Successful in 15s
Harness Replays / detect-changes (pull_request) Successful in 12s
Runtime PR-Built Compatibility / detect-changes (pull_request) Successful in 33s
Secret scan / Scan diff for credential-shaped strings (pull_request) Successful in 11s
gate-check-v3 / gate-check (pull_request_target) Successful in 7s
qa-review / approved (pull_request_target) Successful in 8s
security-review / approved (pull_request_target) Successful in 6s
lint-required-no-paths / lint-required-no-paths (pull_request) Successful in 1m19s
sop-checklist / all-items-acked (pull_request) acked: 0/7 — missing: comprehensive-testing, local-postgres-e2e, staging-smoke, +4 — body-unfilled: comprehensive-testing, local-postgres-e2
sop-checklist / na-declarations (pull_request) N/A: (none)
sop-checklist / all-items-acked (pull_request_target) Successful in 7s
sop-tier-check / tier-check (pull_request_target) Successful in 9s
CI / Platform (Go) (pull_request) Successful in 5m21s
CI / Canvas (Next.js) (pull_request) Successful in 6m29s
CI / Python Lint & Test (pull_request) Successful in 7m23s
CI / all-required (pull_request) Successful in 7m26s
Harness Replays / Harness Replays (pull_request) Successful in 22s
Runtime PR-Built Compatibility / PR-built wheel + import smoke (pull_request) Successful in 15s
CI / Canvas Deploy Reminder (pull_request) Has been skipped
E2E API Smoke Test / E2E API Smoke Test (pull_request) Successful in 2m16s
Handlers Postgres Integration / Handlers Postgres Integration (pull_request) Successful in 2m40s
E2E Chat / E2E Chat (pull_request) Failing after 6m30s
audit-force-merge / audit (pull_request_target) Has been skipped
4146812d5d
The struct was introduced alongside extractCanvasUserMessage but the
function returns map[string]interface{} and never uses the typed
variant. golangci-lint unused check fails on it, blocking CI.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Member

Closing — based on the dead staging fork; this fix is already on main. the hermetic env guards this PR adds already exist (equal or superset) on main: mcp_test.go (6× MOLECULE_ORG_ID), registry_test.go TestValidateAgentURL (MOLECULE_ORG_ID + MOLECULE_DEPLOY_MODE), wsauth_middleware_test.go (11× ADMIN_TOKEN), security_regression__test.go (2×), workspace_provision_test.go (4×). The admin_test_token_test.go hunks target staging-only files that do not exist on main. Per the staging-deprecation cleanup; target main for future PRs.

Closing — based on the dead `staging` fork; this fix is already on `main`. the hermetic env guards this PR adds already exist (equal or superset) on main: mcp_test.go (6× MOLECULE_ORG_ID), registry_test.go TestValidateAgentURL (MOLECULE_ORG_ID + MOLECULE_DEPLOY_MODE), wsauth_middleware_test.go (11× ADMIN_TOKEN), security_regression_*_test.go (2×), workspace_provision_test.go (4×). The admin_test_token*_test.go hunks target staging-only files that do not exist on main. Per the staging-deprecation cleanup; target `main` for future PRs.
devops-engineer closed this pull request 2026-06-01 18:28:35 +00:00
Author
Member

superseded by main; staging fork dead per CTO investigation (main lapped staging by 648 commits, #1743 self-sync). Test hermeticity fixes are already present on main (#1703 and subsequent commits).

superseded by main; staging fork dead per CTO investigation (main lapped staging by 648 commits, #1743 self-sync). Test hermeticity fixes are already present on main (#1703 and subsequent commits).
Some required checks failed
CI / Detect changes (pull_request) Successful in 23s
Block internal-flavored paths / Block forbidden paths (pull_request) Successful in 25s
E2E API Smoke Test / detect-changes (pull_request) Successful in 37s
CI / Shellcheck (E2E scripts) (pull_request) Successful in 54s
Handlers Postgres Integration / detect-changes (pull_request) Successful in 12s
E2E Chat / detect-changes (pull_request) Successful in 15s
Harness Replays / detect-changes (pull_request) Successful in 12s
Runtime PR-Built Compatibility / detect-changes (pull_request) Successful in 33s
Secret scan / Scan diff for credential-shaped strings (pull_request) Successful in 11s
gate-check-v3 / gate-check (pull_request_target) Successful in 7s
qa-review / approved (pull_request_target) Successful in 8s
security-review / approved (pull_request_target) Successful in 6s
lint-required-no-paths / lint-required-no-paths (pull_request) Successful in 1m19s
sop-checklist / all-items-acked (pull_request) acked: 0/7 — missing: comprehensive-testing, local-postgres-e2e, staging-smoke, +4 — body-unfilled: comprehensive-testing, local-postgres-e2
Required
Details
sop-checklist / na-declarations (pull_request) N/A: (none)
sop-checklist / all-items-acked (pull_request_target) Successful in 7s
sop-tier-check / tier-check (pull_request_target) Successful in 9s
CI / Platform (Go) (pull_request) Successful in 5m21s
CI / Canvas (Next.js) (pull_request) Successful in 6m29s
CI / Python Lint & Test (pull_request) Successful in 7m23s
CI / all-required (pull_request) Successful in 7m26s
Required
Details
Harness Replays / Harness Replays (pull_request) Successful in 22s
Runtime PR-Built Compatibility / PR-built wheel + import smoke (pull_request) Successful in 15s
CI / Canvas Deploy Reminder (pull_request) Has been skipped
E2E API Smoke Test / E2E API Smoke Test (pull_request) Successful in 2m16s
Handlers Postgres Integration / Handlers Postgres Integration (pull_request) Successful in 2m40s
E2E Chat / E2E Chat (pull_request) Failing after 6m30s
audit-force-merge / audit (pull_request_target) Has been skipped

Pull request closed

Sign in to join this conversation.
No Reviewers
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: molecule-ai/molecule-core#2101