Skip to content

Fix validation server crash on startup under Express 5 - #139

Merged
durw4rd merged 1 commit into
launchdarkly:mainfrom
durw4rd:fix/server-express5-catch-all
Oct 8, 2026
Merged

durw4rd merged 1 commit into
launchdarkly:mainfrom
durw4rd:fix/server-express5-catch-all

Conversation

@durw4rd

@durw4rd durw4rd commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

npm run start:server crashed on startup with PathError [TypeError]: Missing parameter name at index 1: *. Express 5 (path-to-regexp v8) no longer accepts a bare '*' route path, so the app.all('*', ...) catch-all in server/src/index.ts threw when the app registered its routes.

This PR replaces it with a final app.use((_, res) => ...) handler that returns the same 404 response. No other changes.

Testing

  • npm run start:server builds and prints Validation app listening on port 3000.
  • The README example POST /api/v2/segment-target/<integrationKey> is routed correctly. With a real key (amplitude) it returns 200. With the README's placeholder key it returns the route's own 404 (integration with key ... not found).
  • Unknown routes (GET /nope, POST /api/v2/other/x, GET /) return 404 {"status":404,"message":"not found"}.
  • prettier --check passes.

🤖 Generated with Claude Code


Note

Overview
Fixes a startup crash on Express 5 by swapping the invalid app.all('*', …) catch-all for a terminal app.use middleware that still returns the same 404 not found JSON for unmatched routes.

Behavior for known API routes and integration-specific 404s is unchanged; only how unmatched paths are registered is updated for path-to-regexp v8 compatibility.

Reviewed by Cursor Bugbot for commit 6ce5d09. Bugbot is set up for automated code reviews on this repo. Configure here.

Express 5 (path-to-regexp v8) rejects the bare '*' route path, so
app.all('*', ...) threw 'Missing parameter name at index 1: *' at startup.
Use a final app.use() handler for the 404 catch-all instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@durw4rd
durw4rd requested a review from a team as a code owner September 28, 2026 16:49
@durw4rd
durw4rd requested a lite review from Copilot September 28, 2026 16:50

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

No unresolved issues were identified.

Review effort: Lite
Findings: None

What changed in this PR

Fixes the Express 5 startup crash caused by the unsupported wildcard catch-all route.

Changes:

  • Replaces app.all('*', ...) with terminal app.use(...).
  • Preserves the existing JSON 404 response.
File Description
server/​src/​index.ts Updates catch-all handling for Express 5 compatibility.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@sheldonmartin sheldonmartin left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Tested locally and confirmed it works.

@durw4rd
durw4rd merged commit ec1a11a into launchdarkly:main Oct 8, 2026
8 checks passed
@durw4rd
durw4rd deleted the fix/server-express5-catch-all branch October 8, 2026 15:16
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.

3 participants