Skip to content

fix(functions): keep the query string and urlencoded bodies flat, as deployed functions do - #326

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

Built on #325 (fix(deps), merged), which cleared the Snyk findings that blocked every v2-dev commit.

What was wrong

Deployed AWS functions (lambda-node-bridge/cf-sv-with-helpers.ts) parse the query string (getQueryParser) and an application/x-www-form-urlencoded body (getBodyParser) with Node's querystring. That keeps keys flat: ?a[b]=1&list=1&list=2 gives { 'a[b]': '1', list: ['1', '2'] }.

launch:functions:serve used Express's extended qs parser for both, which reads brackets as structure: { a: { b: '1' } }. A function written against one shape broke on the other. HTML forms that post user[name]=… hit this directly.

This is CL-8970 gap 6.

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

  • app.set('query parser', 'simple'): Express's simple query parser is querystring.parse.
  • express.urlencoded({ extended: false, limit }): body-parser's simple parser is also querystring.
  • Path parameters are still merged into req.query after parsing (gap 5), so { ...query, ...params } matches AWS end to end.
  • AGENTS.md. The approved V1 differences now say the query and urlencoded bodies are flat as on AWS, and that Azure and GCP (V1) nest them.
  • .talismanrc. Refreshed checksums for cloud-functions.test.ts and AGENTS.md (test code and prose, no credentials).

Tests

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

  • keeps the query string flat, as deployed functions do: /query?a[b]=1&list=1&list=2 gives { 'a[b]': '1', list: ['1', '2'] }. It failed before the change (a nested).
  • keeps an urlencoded form flat, as deployed functions do: a[b]=1&c=2&list=1&list=2 gives { 'a[b]': '1', c: '2', list: ['1', '2'] }. It failed before the change.
  • The existing hands a application/x-www-form-urlencoded body to the handler as a parsed object test sent tags[]=a&tags[]=b and expected tags. That pinned the nested behaviour this gap removes; on AWS the key is tags[]. It now sends tags=a&tags=b, the repeated-key form AWS turns into an array, and keeps its expected object. The bracket case has its own test above.

Full suite in the pre-push hook: 189 suites, 3829 tests passed (also after merging v2-dev, at b11d948). Every hook ran, with no --no-verify.

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

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

  • v2-dev d56e39d (before gap 6): 18/25.
  • This branch (b11d948): 22/25. All four flat checks pass, and no check got worse:
    • the query string stays flat;
    • an urlencoded form stays flat;
    • the new a query key ending in [] stays a key;
    • the new an urlencoded form keeps [] in the key and a repeated key as an array.
  • The 3 still failing are later gaps: 8 (req.body with no body; raw request stream) and 10 (require, __dirname).

#500 adds the [] cases (tags[]=a), which qs reads as tags. Azure and GCP (V1) are recorded as known gaps, and everything runs behind LAUNCH_E2E_CLOUD_FUNCTION_PARITY.

Not changed

  • Over 1000 form fields. AWS's querystring.parse keeps the first 1000 keys. body-parser answers 413 "too many parameters" instead, as it already did with qs.
  • A non-UTF-8 charset on a form is refused with 415 by body-parser. AWS ignores the charset. This is unchanged from before.

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


Generated by Claude Code

…deployed functions do

Deployed AWS functions parse the query string and an
application/x-www-form-urlencoded body with Node's querystring, so a[b]=1
stays the key 'a[b]' and a repeated key becomes an array. Serve used
Express's extended qs parser for both, which built nested objects. It now
uses Express's 'simple' query parser and urlencoded({ extended: false }),
both of which are querystring.

The form-body test that sent tags[]=a now sends tags=a, the repeated-key
form AWS parses into an array; the bracket case has its own test. AGENTS.md
records the difference from Azure and GCP (V1), and the .talismanrc
checksums of the two touched files are refreshed.
@chhavi-mandowara-cstk
chhavi-mandowara-cstk requested a review from a team as a code owner December 4, 2026 07:39
@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 0 2 25 ✅ Passed
🟡 Medium Severity 0 10 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: 2
  • Medium without fixes: 10
  • Low without fixes: 0

✅ BUILD PASSED - All security checks passed

dhruv-parekh-cs
dhruv-parekh-cs previously approved these changes Dec 4, 2026
Base automatically changed from CL-snyk-fixes/04-Dec-2026 to v2-dev December 4, 2026 10:03
@chhavi-mandowara-cstk
chhavi-mandowara-cstk dismissed dhruv-parekh-cs’s stale review December 4, 2026 10:03

The base branch was changed.

Brings in the deps fix (#325) as merged, so this branch is up to date
with v2-dev. No file changes beyond gap 6.
@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 0 2 25 ✅ Passed
🟡 Medium Severity 0 10 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: 2
  • Medium without fixes: 10
  • Low without fixes: 0

✅ BUILD PASSED - All security checks passed

@chhavi-mandowara-cstk
chhavi-mandowara-cstk merged commit 424a26d into v2-dev Dec 4, 2026
8 checks passed
@chhavi-mandowara-cstk
chhavi-mandowara-cstk deleted the CL-8970 branch December 4, 2026 10:13
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