Repository navigation
fix(functions): route exactly and answer an empty 404, as deployed functions do - #327
Merged
Merged
Conversation
…nctions do Deployed, nginx sends a request to a cloud function only when its path matches the function's route exactly: an exact-path entry keyed by the URI, or for a [param] route a Lua pattern that must match the whole path. Serve used Express's defaults, so /Hello ran hello.js, /hello/ did too, and a path no function claims got Express's "Cannot GET" HTML page. Serve now turns on Express's case sensitive routing and strict routing, and answers a request no route matched with an empty 404, as the lambda-node-bridge does. Error responses (a malformed body) still go to answerRequestError, since answerNotFound is not an error handler. AGENTS.md records the change, and the .talismanrc checksums of the two touched files are refreshed.
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
🔒 Security Scan Results
⏱️ SLA Breach Summary
ℹ️ Vulnerabilities Without Available Fixes (Informational Only)The following vulnerabilities were detected but do not have fixes available (no upgrade or patch). These are excluded from failure thresholds:
✅ BUILD PASSED - All security checks passed |
Harshi-Shah-CS
approved these changes
Dec 4, 2026
dhruv-parekh-cs
approved these changes
Dec 4, 2026
tejas-contentstack
pushed a commit
that referenced
this pull request
Dec 4, 2026
Brings in the functions fixes from #327, #328 and #329. The only conflict was .talismanrc, the AGENTS.md checksum line: both sides had changed it, so it is recomputed with Talisman for the merged AGENTS.md. All of our other .talismanrc entries are kept as they were. #claude_code# 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <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.
What was wrong
Deployed, nginx (
contentfly-nginx,upstream_proxy.set_proxy_target) sends a request to a cloud function only when its path matches the function's route exactly:details[ngx.var.uri]).[param]route: a Lua pattern that must match the whole URI (string.match(uri, pattern) == uri).The deployment agent (
setup_cloud_functions.go) gives every functions-folder file one of those two route types.HANDLE_ALLis only for a framework's SSR server. Anything else falls through to static hosting, and nginx answers 404 with its own page.launch:functions:serveused Express's defaults:/Helloranhello.js(case-insensitive);/hello/ran it too (trailing slash allowed);Cannot GET /…HTML page.The lambda-node-bridge answers an unmatched path with an empty 404.
This is CL-8970 gap 7.
The change (
src/functions/cloud-functions.ts)app.set('case sensitive routing', true)andapp.set('strict routing', true), set before the firstapp.useso the router picks them up.answerNotFound: a request no route matched gets an empty 404, placed after the function routes. It is not an error handler, so a body that fails to parse still goes toanswerRequestError(the existing malformed-JSON 400 test is unchanged).AGENTS.md. The approved V1 differences now describe exact routing and the empty 404, and that deployed, nginx answers such a request itself..talismanrc. Refreshed checksums forcloud-functions.test.tsandAGENTS.md(test code and prose, no credentials).Tests
src/functions/cloud-functions.test.ts:matches a route only in its exact case, as deployed functions do:/Hellogives 404 and/hellogives 200. It failed before (200).does not match a route with a trailing slash, as deployed functions do:/hello/and/items/42/give 404, and/items/42gives 200. It failed before (200).answers an empty 404 for a path no function claims, as deployed functions do: the existing 404 test, which now also asserts an empty body. It failed before (Express's HTML page).Full suite in the pre-push hook: 189 suites, 3831 tests passed. Every hook ran (Snyk included), with no
--no-verify.E2E (http-sanity cloud-functions checks, AWS expectations)
Against
launch:functions:serve, with the 28 checks from e2e PR contentstack/contentfly-e2e-tests#501:/Queryand/query/answer 200.The new checks assert only the status (404). Deployed, these requests never reach a function and nginx answers with its own page, the same on AWS, Azure and GCP, so they have no known gap.
Not changed
%XXand merges//), so/hell%6Freacheshello.jsdeployed but not under serve. That is path encoding, gap 11.Jira: https://contentstack.atlassian.net/browse/CL-8970
Generated by Claude Code