Skip to content

fix: sanitize imgproxy source image errors#1138

Merged
ferhatelmas merged 1 commit into
masterfrom
ferhat/imgproxy-source-image-bad-request
Jun 8, 2026
Merged

fix: sanitize imgproxy source image errors#1138
ferhatelmas merged 1 commit into
masterfrom
ferhat/imgproxy-source-image-bad-request

Conversation

@ferhatelmas

Copy link
Copy Markdown
Member

What kind of change does this PR introduce?

Bug fix

What is the current behavior?

Source image related errors are returning 500s due to genuine problems in the source such as non-image content, broken format, etc.

What is the new behavior?

Sanitize known errors to well-known messages and return as 400s.

Additional context

It requires enabling dev errors to match error messages. If it's not enabled, no match and current behavior doesn't change.

requires enabling dev errors

Signed-off-by: ferhat elmas <elmas.ferhat@gmail.com>
Copilot AI review requested due to automatic review settings June 8, 2026 09:05
@ferhatelmas ferhatelmas requested a review from a team as a code owner June 8, 2026 09:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adjusts the image-rendering error handling around imgproxy to avoid leaking source-image details (e.g., signed URLs) and to map certain known source-image failures to clearer, client-facing 4xx responses.

Changes:

  • Introduces message/pattern-based mapping for known imgproxy “source image” failures, returning sanitized messages and (for validation failures) 400s.
  • Updates unit tests to cover the new error mapping/sanitization behavior.
  • Adds an acceptance test for a specific imgproxy source-image validation failure case, and updates local infra to pin imgproxy and enable development error messages.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/storage/renderer/image.ts Adds imgproxy error sanitization/mapping helper logic used by handleRequestError.
src/storage/renderer/image.test.ts Expands unit test coverage for sanitized/mapped imgproxy error outputs.
acceptance/specs/cdn-render.test.ts Adds acceptance coverage ensuring a known source-image validation failure returns a 400 with a stable message.
.docker/docker-compose-infra.yml Pins imgproxy version and enables development errors mode for reproducible error-message matching.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/storage/renderer/image.ts
@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 27127194068

Coverage increased (+0.03%) to 76.441%

Details

  • Coverage increased (+0.03%) from the base build.
  • Patch coverage: 17 of 17 lines across 1 file are fully covered (100%).
  • 3 coverage regressions across 1 file.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

3 previously-covered lines in 1 file lost coverage.

File Lines Losing Coverage Coverage
src/storage/protocols/tus/s3-locker.ts 3 78.37%

Coverage Stats

Coverage Status
Relevant Lines: 11037
Covered Lines: 8867
Line Coverage: 80.34%
Relevant Branches: 6468
Covered Branches: 4514
Branch Coverage: 69.79%
Branches in Coverage %: Yes
Coverage Strength: 369.21 hits per line

💛 - Coveralls

@ferhatelmas ferhatelmas merged commit 8efb11a into master Jun 8, 2026
27 checks passed
@ferhatelmas ferhatelmas deleted the ferhat/imgproxy-source-image-bad-request branch June 8, 2026 10:49
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.

4 participants