Skip to content

Comments

Return error object when headers already sent in response-validation handler#554

Open
Copilot wants to merge 2 commits intofeature/fix-headers-sendfrom
copilot/sub-pr-552-again
Open

Return error object when headers already sent in response-validation handler#554
Copilot wants to merge 2 commits intofeature/fix-headers-sendfrom
copilot/sub-pr-552-again

Conversation

Copy link

Copilot AI commented Feb 18, 2026

Addresses inconsistency in response-validation.js where the handler returned undefined when headers were already sent, unlike other error handlers (unauthorized.js, request-validation.js, not-found.js) which always return the error response object.

Changes

  • Removed early return when response.headersSent at function start
  • Modified validation error handling to construct error object unconditionally
  • Conditionally send response via response.status(502).json(errorResponse) only when headers not sent
  • Return error object in all cases to allow downstream inspection of intended response

Before:

if (!response.headersSent) {
  return response.status(502).json({ errors, status: 502, ... })
}
return undefined  // Inconsistent with other handlers

After:

const errorResponse = { errors, status: 502, ... }
if (!response.headersSent) {
  return response.status(502).json(errorResponse)
}
return errorResponse  // Consistent with other handlers

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…lready sent

Co-authored-by: w3nl <3618143+w3nl@users.noreply.github.com>
Copy link
Author

Copilot AI commented Feb 18, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • scarf.sh
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node ./report.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Update response validation to prevent multiple header settings Return error object when headers already sent in response-validation handler Feb 18, 2026
Copilot AI requested a review from w3nl February 18, 2026 15:56
@w3nl w3nl marked this pull request as ready for review February 18, 2026 16:02
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.

2 participants