Skip to content

fix: createContact deserialization on empty success response#112

Open
ps-20x wants to merge 1 commit intogetbrevo:v4from
ps-20x:fix/create-contact-empty-response
Open

fix: createContact deserialization on empty success response#112
ps-20x wants to merge 1 commit intogetbrevo:v4from
ps-20x:fix/create-contact-empty-response

Conversation

@ps-20x
Copy link

@ps-20x ps-20x commented Mar 17, 2026

Summary

Fixes a bug where ContactsClient::createContact() could throw:

Brevo\Exceptions\BrevoException: Failed to deserialize response: Syntax error

when the API returned a successful response with an empty or blank body.

Root cause

createContact() attempted to deserialize every successful response body
as JSON without checking whether the body was empty first.

Changes

  • added a regression test covering a successful empty response body
  • updated ContactsClient::createContact() to handle empty successful responses safely
  • preserved existing behavior for normal valid JSON responses

Result

createContact() no longer throws a JSON syntax error for empty success
responses and remains compatible with the current method contract.

Resolves: #104

@ps-20x ps-20x changed the base branch from main to v4 March 17, 2026 12:40
@sonarqubecloud
Copy link

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.

v4.0.7: ContactsClient::createContact() throws "Failed to deserialize response: Syntax error" for successful contact upsert flow

1 participant