Fix functions deploy broken by the express 5 upgrade - #869
Merged
Conversation
npm update pulled firebase-functions 7.2.5 -> 7.3.2, which brought express 4.22.2 -> 5.2.1 along transitively. Express 5 uses path-to-regexp v8, where the optional-group syntax used by every API route no longer parses: TypeError: Unexpected ( at index 0: (/api)?/aerodrome/status functions/index.js therefore throws on load and firebase deploy --only functions fails during function discovery. Rewrites the six routes to path arrays, which express 5 still supports, and declares express as a direct dependency. It was only ever required, never declared, so it silently rode along on whatever firebase-functions hoisted -- which is how the major bump slipped in unnoticed. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Problem
The
lszm_testfunctions deploy fails (run 438), dying 8 seconds intofirebase deploy --only functions.15c5091("Update dependencies within existing version ranges") bumpedfirebase-functions7.2.5 → 7.3.2, which pulled express 4.22.2 → 5.2.1 in transitively. Express 5 usespath-to-regexpv8, which dropped the optional-group route syntax all six API routes relied on:functions/index.jsthrows on load, so the deploy fails during function discovery. Onlylszmsurfaced it because it was the one environment approved on that run — the other functions jobs were cancelled, not passing.The weakness underneath:
expresswasrequired infunctions/api/index.jsbut never declared infunctions/package.json, so it rode along on whateverfirebase-functionshappened to hoist. That is how a major version bump slipped in unnoticed.Changes
functions/package.json— declare"express": "^5.2.1"as a direct dependency; lockfile regenerated.functions/api/index.js— six routes converted from'(/api)?/x'to['/x', '/api/x'], which express 5 still supports.Verification
npm ci+require('./index.js')→ loads, 31 exports (what deploy discovery does)./customs/invoices→ 200,/api/customs/invoices→ 200, unknown path → 404.npm run test:functions→ 443 passed, 39 suites.npm run typecheck→ clean.npm test→ 2494 passed, 6 failed insrc/components/MovementList/Predicates.spec.ts. Those fail identically on unmodifieddevelop— pre-existing and unrelated (date-boundary/timezone comparisons), not addressed here.🤖 Generated with Claude Code
https://claude.ai/code/session_01DwLp35iqaMTEhtqTcyu4EN