Skip to content

fix: prevent unhandled 5xx in scrape controller on malformed URLs#2292

Open
radhikagpt1208 wants to merge 4 commits intomainfrom
SITES-43697
Open

fix: prevent unhandled 5xx in scrape controller on malformed URLs#2292
radhikagpt1208 wants to merge 4 commits intomainfrom
SITES-43697

Conversation

@radhikagpt1208
Copy link
Copy Markdown
Contributor

JIRA: https://jira.corp.adobe.com/browse/SITES-43697

Two defensive fixes surfaced by the APIGatewayErrorRateHigh alert (SKYSI-76262) where a caller sent base64-encoded multi-line text in place of a URL:

  • getScrapeUrlByProcessingType now validates the decoded URL via isValidUrl() and returns 400 for non-URL input, mirroring getScrapeJobsByBaseURL.

  • createErrorResponse strips CR/LF and truncates error.message before placing it in the x-error header. Without this, multi-line messages threw ERR_INVALID_CHAR from @adobe/fetch's Headers.set, escaped the catch block, and surfaced as unhandled Lambda 500s — the actual driver of the alert burst.

Adds 4 unit tests covering both behaviors.

Thanks for contributing!

…ITES-43697

Two defensive fixes surfaced by the APIGatewayErrorRateHigh alert (SKYSI-76262)
where a caller sent base64-encoded multi-line text in place of a URL:

- getScrapeUrlByProcessingType now validates the decoded URL via isValidUrl()
  and returns 400 for non-URL input, mirroring getScrapeJobsByBaseURL.

- createErrorResponse strips CR/LF and truncates error.message before placing
  it in the x-error header. Without this, multi-line messages threw
  ERR_INVALID_CHAR from @adobe/fetch's Headers.set, escaped the catch block,
  and surfaced as unhandled Lambda 500s — the actual driver of the alert burst.

Adds 4 unit tests covering both behaviors.
@radhikagpt1208 radhikagpt1208 requested a review from habansal April 29, 2026 15:39
@github-actions
Copy link
Copy Markdown

This PR will trigger a patch release when merged.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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.

1 participant