Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add execption handler for guzzle_json_decode #40

Merged
merged 1 commit into from
Apr 3, 2020

Conversation

emsyzz
Copy link
Contributor

@emsyzz emsyzz commented Mar 30, 2020

If request fails - \Contentful\Core\Api\Requester::createCustomException is called, which assumes that response body will always be valid JSON string - but unfortunately in rare cases it isn't. Invalid response body passed to guzzle_json_decode results in InvalidArgumentException witch MUST be caught otherwise it propagates up the frame and source of original exception no longer can be determined.

This Pull Request adds additional exception handling for cases when guzzle_json_decode fails and adds additional exception class for such cases.

Add exception class for invalid response body
@emsyzz emsyzz changed the title Add execption handler for gazzle_json_decode Add execption handler for guzzle_json_decode Mar 31, 2020
@pgrigoruta pgrigoruta merged commit 92220a1 into contentful:master Apr 3, 2020
@pgrigoruta
Copy link
Contributor

Thanks @emsyzz ! We just merged your PR into the latest release and added one coverage test.

@emsyzz
Copy link
Contributor Author

emsyzz commented Apr 3, 2020

Thank you @phoebeschmidt for such fast response. When I could expect those changes to be incorporated with management library?
I'm currently using 2.0 version of management library. Is version 2.x still being supported or I should move to 3.x?

@pgrigoruta
Copy link
Contributor

@emsyzz , I don't see this code being duplicated in the management library, so you should be fine by running composer update to pull a new version of the core, when on 3.x.

I strongly encourage to upgrade to 3.x. The "breaking" change that happened in 3 is that we added support for PHP 7.4, dropped support for PHP 7.0 and 7.1 and also upgraded all deps. Unless you are on PHP 7.0 or 7.1, the upgrade will be smooth.

We don't currently plan to support 2.x anymore as generally we try to support the PHP versions that are not eol and between 7.1 and 7.4 we can have one or another.

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.

None yet

2 participants