Skip to content

fix(wasm): check HTTP status before deserializing response body - #625

Open
sanskar-soni-9 wants to merge 2 commits into
supabase:mainfrom
sanskar-soni-9:fix/wasm-fdw-error-handling
Open

fix(wasm): check HTTP status before deserializing response body#625
sanskar-soni-9 wants to merge 2 commits into
supabase:mainfrom
sanskar-soni-9:fix/wasm-fdw-error-handling

Conversation

@sanskar-soni-9

Copy link
Copy Markdown
Contributor

What kind of change does this PR introduce?

Bug fix

What is the current behavior?

When upstream APIs reject a connection (e.g., 401 Unauthorized or 403 Forbidden) and return a non-JSON error body (such as HTML or plain text), WASM Foreign Data Wrappers fail during JSON deserialization (serde_json::from_str) with a generic error: ERROR: HV000: guest fdw error: expected value at line 1 column 1

This occurs because WASM wrappers blindly attempt to deserialize the response body into JSON before checking the HTTP status code via http::error_for_status, hiding the actual HTTP error status and response body from PostgreSQL logs.

Closes: #386

What is the new behavior?

  • Ensures http::error_for_status(&resp) is checked before attempting serde_json::from_str across WASM FDWs (snowflake_fdw, cal_fdw, calendly_fdw, cfd1_fdw, notion_fdw, paddle_fdw).
  • Preserves missing-object 404 logic in notion_fdw and paddle_fdw while ensuring unexpected 404 or HTTP error responses properly bubble up the HTTP status and body text.
  • Enriches HTTP error mappings in snowflake_fdw polling loops so response bodies are included in error messages.

@sanskar-soni-9

Copy link
Copy Markdown
Contributor Author

@burmecia the CI is green now - please take a look when you get a chance

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.

connect to snowflake returns generic FDW error.

1 participant