Skip to content

fix(functions): ignore a second argument to res.json, as deployed functions do - #312

Merged
chhavi-mandowara-cstk merged 4 commits into
v2-devfrom
CL-8970
Nov 27, 2026
Merged

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

Conversation

@chhavi-mandowara-cstk

@chhavi-mandowara-cstk chhavi-mandowara-cstk commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

What was wrong

Deployed AWS functions (lambda-node-bridge/cf-sv-with-helpers.ts) and Vercel's @vercel/node define res.json = (jsonBody) => json(req, res, jsonBody): one argument, JSON.stringify, application/json; charset=utf-8 unless a content type is already set, current status kept. Locally, launch:functions:serve uses Express 4's res.json, which still honours the deprecated two-argument forms and sets the status from them.

Handler AWS / Vercel serve before serve after
res.json(404, { error: 'missing' }) 200, 404 404, {"error":"missing"} same as AWS
res.json({ ok: false }, 500) 200, {"ok":false} 500 same as AWS
res.status(201).json({ id: 'a1' }) 201 201 unchanged
res.type('text/plain').json({ a: 1 }) 200, text/plain kept same unchanged

Found in the review of gap 3 (#311), which made res.send one-argument the same way. Added to CL-8970 as gap 12, agreed with Dhruv.

The change

  • src/functions/cloud-functions.ts: in the existing sendLikeDeployedFunctions middleware, res.json now passes only its first argument on to Express's json.
  • AGENTS.md: the approved V1 differences note that res.json takes one argument too, and that Azure/GCP (V1, Express 4) still honour the two-argument forms of res.send and res.json.
  • .talismanrc: refreshed checksums for cloud-functions.test.ts and AGENTS.md (test code and prose, no credentials).

Tests

  • src/functions/cloud-functions.test.ts: one regression test (ignores a second argument to res.json and keeps the current status, as deployed functions do). It failed before the fix with Express's 404, and it also asserts a status set with res.status() and a content type already set are kept.
  • Mutation checks: forwarding every argument again, or forcing an application/json content type, turns the test red.
  • File: 70/70. Full suite in the pre-push hook: 201 suites, 4115 tests passed.

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

v2-dev 3604ddc: 8/15; this branch: 8/15, no check changed. None of the 15 checks covers the two-argument res.json form yet; adding one needs an e2e PR in contentfly-e2e-tests behind LAUNCH_E2E_CLOUD_FUNCTION_PARITY, with Azure/GCP knownGaps (Express's status).

Notes

  • Every commit and the push ran the full hooks (lint-staged, Talisman, trufflehog, Snyk, and the full suite on push), no --no-verify. The pre-push trufflehog step scanned 0 chunks in this shallow clone, so trufflehog was run by hand on the 4 changed files: 0 secrets.
  • ggshield is not installed in this environment, so its hook step printed its skip notice.

QA: the Launch QA agent tests CL-8970 in the repos once it is in QA; GoCD sanity covers dev11.

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

…ctions do

Deployed functions (lambda-node-bridge and Vercel's @vercel/node) define
res.json with one argument and keep the current status. Express 4 still
honours its deprecated res.json(status, body) and res.json(body, status)
forms, so serve answered 404 or 500 where a deployed function answers 200.
Pass only the first argument on, and record it in the approved V1
differences.
…AGENTS.md

Test code and prose; no credentials.
@snyk-io

snyk-io Bot commented Nov 26, 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

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 1 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: 1
  • Low without fixes: 0

✅ BUILD PASSED - All security checks passed

@chhavi-mandowara-cstk
chhavi-mandowara-cstk merged commit 8899a3e into v2-dev Nov 27, 2026
7 checks passed
@chhavi-mandowara-cstk
chhavi-mandowara-cstk deleted the CL-8970 branch November 27, 2026 05:57
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