Skip to content

fix(functions): add path parameters to req.query, as deployed functions do - #324

Merged
chhavi-mandowara-cstk merged 2 commits into
v2-devfrom
CL-8970
Dec 4, 2026
Merged

chhavi-mandowara-cstk merged 2 commits into
v2-devfrom
CL-8970

Conversation

@chhavi-mandowara-cstk

@chhavi-mandowara-cstk chhavi-mandowara-cstk commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

What was wrong

Deployed AWS functions (lambda-node-bridge/cf-sv-with-helpers.ts) build req.query from the query string with the path parameters spread over it: { ...parseQS(rawQueryString), ...pathParameters }. Under launch:functions:serve, path parameters were only in req.params, so a function reading req.query.id on a [id].js route got undefined locally and the value on AWS.

This is CL-8970 gap 5.

The change (src/functions/cloud-functions.ts)

  • Before the handler runs, serve sets request.query = { ...request.query, ...request.params }.
  • A path parameter wins over a query value of the same name, as on AWS: /items/abc?id=zzz gives req.query.id === 'abc'.
  • req.params is unchanged.
  • AGENTS.md. The approved V1 differences now say this, and that Azure and GCP (V1) keep path parameters only in request.params.
  • .talismanrc. Refreshed checksums for cloud-functions.test.ts and AGENTS.md (test code and prose, no credentials).

Tests

src/functions/cloud-functions.test.ts:

  • adds path parameters to the query, as deployed functions do: /api/items/abc?x=1 gives query { x: '1', id: 'abc' } and params { id: 'abc' }. It failed before the change.
  • lets a path parameter win over a query value of the same name, as deployed functions do: /api/items/abc?id=zzz gives { id: 'abc' }. Swapping the spread order turns it red.

Full suite in the pre-push hook: 189 suites, 3827 tests passed. Every hook ran, with no --no-verify.

E2E (http-sanity cloud-functions checks, AWS expectations)

Against launch:functions:serve, with the checks from e2e PR contentstack/contentfly-e2e-tests#499:

  • v2-dev 4c4eed9: 16/23. Both path-param checks fail (query { x: '1' }; query { id: 'zzz' }).
  • This branch: 18/23. path params are also in req.query and the new a path param wins over a query value of the same name both pass, and no check got worse.
  • The 5 that still fail are later gaps (6, 8, 10).

The new check runs only with LAUNCH_E2E_CLOUD_FUNCTION_PARITY=on. Azure and GCP keep the query value, recorded as a CL-8970 known gap.

Not changed

  • Decoding. Express decodes path parameters (/items/a%20b → a b); AWS splits the raw path. req.query carries the same value as req.params. Whether AWS decodes is not verified, and that is the existing req.params behaviour, outside this gap.
  • Express 5. req.query is a getter there, so this assignment would need Object.defineProperty. launch-cli pins Express 4.

Jira: https://contentstack.atlassian.net/browse/CL-8970


Generated by Claude Code

…ns do

Deployed AWS functions build req.query from the query string and the path
parameters. Serve now does the same, so a function reading a path parameter
from req.query gets it locally too.
… the same name

Document in AGENTS.md that request.query holds the path parameters on
AWS and serve, and only request.params on Azure and GCP (V1). Refresh
the .talismanrc checksums of the two touched files.
@chhavi-mandowara-cstk
chhavi-mandowara-cstk requested a review from a team as a code owner December 4, 2026 06:30
@snyk-io

snyk-io Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues
✅ Licenses 0 0 0 0 0 issues
✅ Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@github-actions

github-actions Bot commented Dec 4, 2026

Copy link
Copy Markdown

🔒 Security Scan Results

ℹ️ Note: Only vulnerabilities with available fixes (upgrades or patches) are counted toward thresholds.

Check Type Count (with fixes) Without fixes Threshold Result
🔴 Critical Severity 0 0 10 ✅ Passed
🟠 High Severity 4 14 25 ✅ Passed
🟡 Medium Severity 2 13 500 ✅ Passed
🔵 Low Severity 0 0 1000 ✅ Passed

⏱️ SLA Breach Summary

✅ No SLA breaches detected. All vulnerabilities are within acceptable time thresholds.

Severity Breaches (with fixes) Breaches (no fixes) SLA Threshold (with/no fixes) Status
🔴 Critical 0 0 15 / 30 days ✅ Passed
🟠 High 0 0 30 / 120 days ✅ Passed
🟡 Medium 0 0 90 / 365 days ✅ Passed
🔵 Low 0 0 180 / 365 days ✅ Passed

ℹ️ 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:

  • Critical without fixes: 0
  • High without fixes: 14
  • Medium without fixes: 13
  • Low without fixes: 0

✅ BUILD PASSED - All security checks passed

@chhavi-mandowara-cstk
chhavi-mandowara-cstk merged commit 2292b73 into v2-dev Dec 4, 2026
8 checks passed
@chhavi-mandowara-cstk
chhavi-mandowara-cstk deleted the CL-8970 branch December 4, 2026 07:19
tejas-contentstack pushed a commit that referenced this pull request Dec 4, 2026
Brings in PR #324 (cloud-functions path parameters in request.query).
Conflicted file: .talismanrc, the AGENTS.md checksum entry, resolved by
keeping both sides' AGENTS.md changes and refreshing its checksum.

#claude_code#
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <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.

5 participants