Skip to content

fix(deploy): catch missing prod alias before functions deploy#4

Open
chrishonson wants to merge 1 commit into
mainfrom
fix/deploy-alias-validation
Open

fix(deploy): catch missing prod alias before functions deploy#4
chrishonson wants to merge 1 commit into
mainfrom
fix/deploy-alias-validation

Conversation

@chrishonson

Copy link
Copy Markdown
Owner

Summary

  • Root cause fixed: Firebase CLI v14+ displays the resolved project ID in firebase use output whether the project was set via firebase use prod (alias, picks up functions/.env.prod) or firebase use my-brain-88870 (raw project ID, skips functions/.env.prod). This made the two indistinguishable, so a deploy with the wrong context silently omitted MCP_CLIENT_PROFILES_JSON, causing all /clients/:id/mcp endpoints to return 404.
  • Preflight hardened: reads the Firebase CLI configstore directly to verify the stored value is the prod alias (not the raw project ID); fails with an actionable error if wrong.
  • Deployment playbook updated: new post-deploy step 3 does a quick CORS preflight against both client endpoints immediately after deploy to catch missing client profiles before the full smoke test; deploy step 5 warns that --project my-brain-88870 silently skips .env.prod and documents --project prod as the safe explicit form.

What broke and how it was found

All /clients/:clientId/mcp endpoints were returning 404 in production. The /healthz and admin /mcp endpoint were healthy. Investigation showed MCP_CLIENT_PROFILES_JSON was absent from the deployed function — it lives only in functions/.env.prod, not functions/.env. The function had been deployed without the prod alias active (or before .env.prod was populated), so Firebase never bundled .env.prod.

Redeploying with firebase use prod confirmed via Loaded environment variables from .env, .env.prod. in the deploy output. All client endpoints resolved immediately and the admin smoke test passed end-to-end.

Test plan

  • Preflight == Firebase project == section now prints Alias 'prod' confirmed (stored: 'prod' → my-brain-88870) when correct
  • Simulated the failure path: storing my-brain-88870 in place of prod produces the expected error message and non-zero exit
  • Redeployed production function; firebase deploy log confirmed .env.prod was bundled
  • All client CORS preflights return 204; admin MCP smoke test passes end-to-end

🤖 Generated with Claude Code

Firebase CLI v14+ shows the resolved project ID in `firebase use` output
whether the project was set via alias (prod) or raw project ID (my-brain-88870),
making them indistinguishable. Deploying with the raw project ID silently skips
functions/.env.prod, leaving MCP_CLIENT_PROFILES_JSON out of the bundle and
causing all /clients/:id/mcp endpoints to 404.

- preflight: read the Firebase CLI configstore directly to verify the stored
  value is the 'prod' alias, not the raw project ID; fail with a clear error
  and fix command if wrong
- DEPLOYMENT.md step 5: warn that --project my-brain-88870 silently skips
  .env.prod; use --project prod if an explicit flag is needed
- DEPLOYMENT.md post-deploy: add step 3 — quick CORS preflight against both
  client endpoints immediately after deploy to catch missing client profiles
  before the full smoke test

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

2 participants