Skip to content

fix: add code into errors - #1256

Merged
ferhatelmas merged 1 commit into
masterfrom
ferhat/error-code
Jul 23, 2026
Merged

ferhatelmas merged 1 commit into
masterfrom
ferhat/error-code

Conversation

@ferhatelmas

@ferhatelmas ferhatelmas commented Jul 23, 2026 •

Copy link
Copy Markdown
Member

What kind of change does this PR introduce?

Bug fix

What is the current behavior?

Code is missing from shared error schema so it's removed in serialization.

What is the new behavior?

Extend error schema to include code, handling a few missing cases and cover with tests.

Additional context

Related to https://supabase.com/docs/guides/storage/debugging/error-codes
Related to supabase/supabase-js#2537

Copilot AI review requested due to automatic review settings July 23, 2026 10:55
@ferhatelmas
ferhatelmas requested a review from a team as a code owner July 23, 2026 10:55

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coveralls

coveralls commented Jul 23, 2026 •

Copy link
Copy Markdown

Coverage Report for CI Build 30003303204

Coverage increased (+0.09%) to 80.395%

Details

  • Coverage increased (+0.09%) from the base build.
  • Patch coverage: 21 of 21 lines across 9 files are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 12906
Covered Lines: 10810
Line Coverage: 83.76%
Relevant Branches: 7599
Covered Branches: 5675
Branch Coverage: 74.68%
Branches in Coverage %: Yes
Coverage Strength: 415.28 hits per line

💛 - Coveralls

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM. This is a well-tested, mechanical fix: it adds a required code field to the shared error response schema (previously silently stripped during serialization) and wires it through existing error paths (rate limiter, tenant-feature guard, renderer, 404s).

Extended reasoning...

Overview

The PR extends errorSchema (src/http/schemas/error.ts) to include a code field and adds a shared sharedErrorResponseSchemas object covering both 4xx and 5xx responses. It then threads code through the handful of places that construct error bodies by hand (tenant-feature plugin, render rate-limiter, image renderer's 404/abort responses) and swaps route-level response schemas from a bare 4xx ref to the shared 4xx/5xx schema across the object, vector, render, bucket, and cdn route groups. It also adds a new setRestNotFoundHandler that gives each top-level REST route group (bucket, object, render, cdn, vector) a schema-consistent 404 body instead of Fastify's default. The bulk of the diff (most of the line count) is test updates asserting the new code field and the new 404 behavior.

Security risks

None. This is response-shape/serialization only — no new auth, crypto, or data-exposure surface. The code values are drawn from the existing ErrorCode enum already used internally, so no new information is exposed that wasn't already computed server-side.

Level of scrutiny

Moderate scrutiny is warranted given the file count (44), but the actual behavioral change is narrow and mechanical: add a field to a schema, and consistently pass a code value everywhere an error object is already constructed. I traced the core error-handler (src/http/error-handler.ts, unchanged by this diff) and confirmed every code path there already emits code via ErrorCode/StorageError.render(), so extending the schema simply stops that field from being silently dropped by fastify's serializer rather than introducing new logic. The new not-found-handler.ts is also simple — it explicitly compiles and applies the errorSchema serializer for unmatched routes within each REST route group, verified against src/test/app.test.ts to confirm non-REST protocol handlers (S3, iceberg) are left untouched.

Other factors

Test coverage is extensive and directly targets the changed behavior — new tests assert code in bucket/object/vector/render error responses, new 404 tests per route group, and renderer abort/not-found tests. No CODEOWNER-restricted paths or auth/permission logic are touched. No bugs were reported by the bug-hunting pass, and my own read of the diff didn't surface any correctness concerns beyond what's already covered by tests.

Signed-off-by: ferhat elmas <elmas.ferhat@gmail.com>
@ferhatelmas
ferhatelmas merged commit e845f99 into master Jul 23, 2026
38 of 39 checks passed
@ferhatelmas
ferhatelmas deleted the ferhat/error-code branch July 23, 2026 11:37
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