molecule-core/canvas/src/lib
Hongming Wang a6477d2b0c fix(canvas): boot-time matched-pair guard for ADMIN_TOKEN env vars (#175)
Closes the post-PR-#174 self-review gap: the matched-pair contract
between ADMIN_TOKEN (server-side bearer gate) and NEXT_PUBLIC_ADMIN_TOKEN
(canvas client-side bearer attach) was descriptive only, living in a
.env file comment. Future agents/devs could re-misconfigure with one
of the two unset and silently 401 — every workspace API call refused
with no actionable diagnostic.

Adds checkAdminTokenPair() to canvas/next.config.ts, run after
loadMonorepoEnv() so it sees the post-load state. Two distinct
warnings (server-set/client-unset and the inverse) so an operator can
tell which half is missing without grep'ing. Empty string is treated
as unset so KEY= and unset KEY produce the same verdict.

Warn-only, not exit — production canvas Docker images bake these vars
at image-build time and a hard exit would turn a recoverable auth
issue into a crashloop. The console.error fires in `next dev`, the
standalone server's stdout, and the canvas Docker container logs —
the three places an operator looks when "everything 401s."

Tests pin exact stderr strings (per feedback_assert_exact_not_substring)
across 6 cases: both unset, both set, ADMIN_TOKEN-only, NEXT_PUBLIC-only,
empty-string-as-unset, and the empty-string-asymmetric mismatch.
Mutation-tested: flipping the if-condition from === to !== fails all 6.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-08 19:22:39 -07:00
..
__tests__ fix(canvas): boot-time matched-pair guard for ADMIN_TOKEN env vars (#175) 2026-05-08 19:22:39 -07:00
api feat(canvas): SaaS cross-origin — slug header + cookie credentials (Phase F) 2026-04-14 20:08:39 -07:00
validation fix(ci): handle merge_group + shallow-clone BASE in secret-scan 2026-04-26 14:08:19 -07:00
api.ts fix(canvas): consolidate platform-auth headers via shared helper (#178) 2026-05-07 14:36:02 -07:00
auth.ts fix(canvas): consume CP logout_url to break the SSO re-auth loop 2026-05-05 12:21:49 -07:00
billing.ts fix(canvas): apply flat-rate pricing copy for Phase 34 launch (Issue #1833) 2026-04-24 17:54:23 +00:00
canvas-actions.ts initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
credits.ts feat(canvas): warm-paper theme + Tailwind v4 migration 2026-05-03 01:43:55 -07:00
deploy-preflight.ts review: drop destructive Override + single-fetch configuredKeys 2026-05-01 13:40:58 -07:00
design-tokens.ts feat(canvas): render misconfigured workspaces with the configuration_status from agent_card 2026-05-04 15:14:40 -07:00
hydrate.ts initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
runtime-names.ts initial commit — Molecule AI platform 2026-04-13 11:55:37 -07:00
runtimeProfiles.ts refactor(canvas): remove RUNTIME_PROFILES.hermes — value flows server-side now (#2054 phase 3) 2026-04-26 07:12:44 -07:00
services.ts refactor(secrets): strip Service dropdown from Add-Key form 2026-04-22 16:41:43 -07:00
tenant.ts fix(canvas): align tier text contracts with 4-tier reality (T1/T2/T3/T4) 2026-05-03 05:56:18 -07:00
theme-cookie.ts feat(canvas): warm-paper theme + Tailwind v4 migration 2026-05-03 01:43:55 -07:00
theme-provider.tsx feat(canvas): warm-paper theme + Tailwind v4 migration 2026-05-03 01:43:55 -07:00
theme.ts feat(canvas): warm-paper theme + Tailwind v4 migration 2026-05-03 01:43:55 -07:00
utils.ts chore(canvas): initialize shadcn/ui — components.json + cn utility 2026-04-18 07:57:17 -07:00
ws-close.ts fix(canvas): Legend avoids TemplatePalette + silence WS handshake races 2026-04-23 16:03:01 -07:00
ws-url.ts fix: code review findings — token UI, auth hardening, WS dedup 2026-04-16 10:42:26 -07:00