Fix ALLOWED_ORIGINS being silently truncated on deploy - #95
Merged
Conversation
deploy-cloudrun's env_vars input parses commas as separators between KEY=VALUE entries (per its action.yml), so ALLOWED_ORIGINS's own comma-separated value (https://www.danibsheehan.com,http://localhost:5173) was silently split into a valid ALLOWED_ORIGINS=https://www.danibsheehan.com entry and a second, garbage, name-only entry — on every deploy so far. The live service only ever had one allowed origin. Found live: testing the frontend-client branch locally produced "Could not summarize this page." Cloud Run request logs showed only CORS preflight (OPTIONS, 204) with no follow-up POST ever arriving — the browser was rejecting the preflight response itself. Reproduced directly against the deployed service (curl OPTIONS) and found the response missing access-control-allow-origin entirely; confirmed via `gcloud run services describe` that ALLOWED_ORIGINS was split as described above, so http://localhost:5173 was never actually allowed. Fix: escape the comma (\,, per the action's documented escaping) at deploy time in a dedicated step, rather than requiring the GitHub secret itself to store a pre-escaped value — keeps the secret in plain, readable form as more origins get added later. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
PR guideAuto-generated from changed paths. Fill in Summary and How to verify in the PR description above. Touches: CI / GitHub Diff: 1 file changed, 14 insertions(+), 1 deletion(-) Suggested verify
Checklist (applies to this PR)
Reviewer focus
Commits
Files by area
CIPrimary check: CI runs lint, Prettier format check, Vitest coverage, and build for every PR. Coverage tables are posted separately. Template: |
|
Unit tests (Vitest)
Minimum allowed coverage is Generated by 🐒 cobertura-action against f874905 |
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Found live while testing #94 locally: the Summarize button failed with "Could not summarize this page." Cloud Run logs showed only CORS preflight (`OPTIONS`, 204) — no actual `POST` ever arrived. Reproduced directly against the deployed service and found the preflight response missing `access-control-allow-origin` entirely.
Root cause: `deploy-cloudrun`'s `env_vars` input parses commas as separators between `KEY=VALUE` entries. `ALLOWED_ORIGINS`'s own value (`https://www.danibsheehan.com,http://localhost:5173\`) contains a comma, so it silently split into a valid `ALLOWED_ORIGINS=https://www.danibsheehan.com\` entry and a second, garbage, name-only entry — confirmed via `gcloud run services describe`. The deployed service has only ever had one allowed origin, on every deploy so far.
Fix
Escape the comma (`,`, per the action's own documented escaping) in a dedicated workflow step at deploy time, rather than requiring the GitHub secret itself to store a pre-escaped value — keeps the secret plain and readable as more origins get added later.
`/code-review` finding (low severity, already mitigated): escaping before writing to `GITHUB_OUTPUT` means GitHub's automatic secret-masking (which matches the literal registered secret string) won't match the escaped form if it ever appears in debug logs. Mitigated by `ALLOWED_ORIGINS` being non-sensitive by design (that's why it's a plain env var, not a Secret Manager entry) — not fixed further.
Test plan
https://www.danibsheehan.com,http://localhost:5173→https://www.danibsheehan.com\,http://localhost:5173🤖 Generated with Claude Code