Skip to content

fix(functions): match response Content-Type case-insensitively#2515

Merged
kallebysantos merged 1 commit into
supabase:masterfrom
PedroHenrique0713:fix/functions-response-content-type-case
Jul 21, 2026
Merged

fix(functions): match response Content-Type case-insensitively#2515
kallebysantos merged 1 commit into
supabase:masterfrom
PedroHenrique0713:fix/functions-response-content-type-case

Conversation

@PedroHenrique0713

Copy link
Copy Markdown
Contributor

🔍 Description

What changed?

FunctionsClient.invoke() matched the response Content-Type case-sensitively when deciding how to parse the body (responseType === 'application/json', etc.). This normalizes the media type to lower case before matching.

Why was this change needed?

HTTP media types are case-insensitive (RFC 9110 §8.3.1). If an Edge Function responds with Content-Type: Application/JSON (or APPLICATION/JSON), the client currently falls through to the text branch and returns the raw, unparsed string instead of the parsed JSON object.

It's also inconsistent with the request side, which already detects the caller's Content-Type case-insensitively (key.toLowerCase() === 'content-type'); only the response side wasn't.

🔄 Breaking changes

  • This PR contains no breaking changes

The compared media types are all lower case already, so lower-casing the incoming value only makes matching more tolerant.

📋 Checklist

  • I have read the Contributing Guidelines
  • My PR title follows the conventional commit format
  • I have run pnpm nx format to ensure consistent code formatting
  • I have added tests for new functionality (if applicable)
  • I have updated documentation (if applicable)

📝 Additional notes

Added test/spec/response-content-type.spec.ts — a unit test (no relay) using a mocked customFetch asserting that lowercase, mixed-case, and uppercase application/json responses all parse as JSON. Verified locally: the mixed/upper cases fail without the change and pass with it; jest (new spec) → 3 passed, tsc --noEmit → clean, prettier --check → clean.

@PedroHenrique0713
PedroHenrique0713 requested review from a team as code owners July 12, 2026 00:50
@pkg-pr-new

pkg-pr-new Bot commented Jul 20, 2026

Copy link
Copy Markdown

Open in StackBlitz

@supabase/auth-js

npm i https://pkg.pr.new/@supabase/auth-js@2515

@supabase/functions-js

npm i https://pkg.pr.new/@supabase/functions-js@2515

@supabase/postgrest-js

npm i https://pkg.pr.new/@supabase/postgrest-js@2515

@supabase/realtime-js

npm i https://pkg.pr.new/@supabase/realtime-js@2515

@supabase/storage-js

npm i https://pkg.pr.new/@supabase/storage-js@2515

@supabase/supabase-js

npm i https://pkg.pr.new/@supabase/supabase-js@2515

commit: 703c55b

@kallebysantos

Copy link
Copy Markdown
Member

Vlw ai manim 💚

@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 94.167% (+13.7%) from 80.446% — PedroHenrique0713:fix/functions-response-content-type-case into supabase:master

@kallebysantos
kallebysantos merged commit 2f54af1 into supabase:master Jul 21, 2026
27 of 28 checks passed
mandarini pushed a commit to supabase/supabase that referenced this pull request Jul 22, 2026
This PR updates @supabase/*-js libraries to version 2.110.8.

**Source**: supabase-js-stable-release

**Changes**:
- Updated @supabase/supabase-js to 2.110.8
- Updated @supabase/auth-js to 2.110.8
- Updated @supabase/realtime-js to 2.110.8
- Updated @supabase/postgest-js to 2.110.8
- Refreshed pnpm-lock.yaml

---

## Release Notes

## v2.110.8

## 2.110.8 (2026-07-21)

### 🩹 Fixes

- **auth:** downgrade aborted/transient fetch failures from
console.error to warn
([#2544](supabase/supabase-js#2544))
- **functions:** clean up cross-signal abort listener on invoke() return
([#2487](supabase/supabase-js#2487))
- **functions:** match response Content-Type case-insensitively
([#2515](supabase/supabase-js#2515))
- **storage:** url-encode object key in CDN purge methods
([#2545](supabase/supabase-js#2545))
- **supabase:** skip Node warning in Deno
([#2541](supabase/supabase-js#2541))

### ❤️ Thank You

- Franco Kaddour @FrancoKaddour
- Katerina Skroumpelou @mandarini
- Pedro Henrique
- Vaibhav @7ttp
## v2.110.7

## 2.110.7 (2026-07-16)

### 🩹 Fixes

- **postgrest:** correct self-reference inference
([#2525](supabase/supabase-js#2525))
- **realtime:** trigger set auth on INITIAL_SESSION event
([#2531](supabase/supabase-js#2531))
- **realtime:** update phoenix to fix presence issue
([#2532](supabase/supabase-js#2532))

### ❤️ Thank You

- Eduardo Gurgel
- Filipe Cabaço @filipecabaco
- Vaibhav @7ttp

This PR was created automatically.

Co-authored-by: supabase-workflow-trigger[bot] <266661614+supabase-workflow-trigger[bot]@users.noreply.github.com>
mandarini pushed a commit to supabase/ssr that referenced this pull request Jul 22, 2026
This PR updates `@supabase/supabase-js` to v2.110.8.

**Source**: supabase-js-stable-release

---

## Release Notes

## v2.110.8

## 2.110.8 (2026-07-21)

### 🩹 Fixes

- **auth:** downgrade aborted/transient fetch failures from
console.error to warn
([#2544](supabase/supabase-js#2544))
- **functions:** clean up cross-signal abort listener on invoke() return
([#2487](supabase/supabase-js#2487))
- **functions:** match response Content-Type case-insensitively
([#2515](supabase/supabase-js#2515))
- **storage:** url-encode object key in CDN purge methods
([#2545](supabase/supabase-js#2545))
- **supabase:** skip Node warning in Deno
([#2541](supabase/supabase-js#2541))

### ❤️ Thank You

- Franco Kaddour @FrancoKaddour
- Katerina Skroumpelou @mandarini
- Pedro Henrique
- Vaibhav @7ttp

This PR was created automatically.

Co-authored-by: supabase-workflow-trigger[bot] <266661614+supabase-workflow-trigger[bot]@users.noreply.github.com>
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