fix(wasm): check HTTP status before deserializing response body - #625
Open
sanskar-soni-9 wants to merge 2 commits into
Open
fix(wasm): check HTTP status before deserializing response body#625sanskar-soni-9 wants to merge 2 commits into
sanskar-soni-9 wants to merge 2 commits into
Conversation
Contributor
Author
|
@burmecia the CI is green now - please take a look when you get a chance |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 1This 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?
http::error_for_status(&resp)is checked before attemptingserde_json::from_stracross WASM FDWs (snowflake_fdw,cal_fdw,calendly_fdw,cfd1_fdw,notion_fdw,paddle_fdw).notion_fdwandpaddle_fdwwhile ensuring unexpected 404 or HTTP error responses properly bubble up the HTTP status and body text.snowflake_fdwpolling loops so response bodies are included in error messages.