Skip to content

Emit JSON errors from PHP Parser #70

New issue

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

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

Already on GitHub? # to your account

Merged
merged 1 commit into from
Jan 4, 2016
Merged

Conversation

wfleming
Copy link
Contributor

@wfleming wfleming commented Jan 4, 2016

The PHP parser had a bug here in that it presumed JSON encoding would
succeed (and there are reasons it might not). This checks the return
value of json_encode and emits a relevant error message if
appropriate. Before this, a triggering case would result in empty output
and an unhelpful error message from JSON.parse upstream in the Ruby
code.

👀 @codeclimate/review

FWIW the triggering code that led me to this was a source file that contained the string ".Inf": PHP's encode_json considers that to actually be a reference to the value INF (Infinity), which isn't a valid JSON value. I'm still looking into what the best remediation for that specific issue might be. My kingdom for a type system that doesn't boil down to "everything is either a string or a map".

@wfleming wfleming force-pushed the will/json-octet-error branch from 53d4f67 to 4ee50f4 Compare January 4, 2016 03:58
@pbrisbin
Copy link
Contributor

pbrisbin commented Jan 4, 2016

My kingdom for a type system that doesn't boil down to "everything is either a string or a map".

Oh have I got a language for you!

@pbrisbin
Copy link
Contributor

pbrisbin commented Jan 4, 2016

LGTM

@wfleming
Copy link
Contributor Author

wfleming commented Jan 4, 2016

Oh have I got a language for you!

I was waiting for the Haskell reference :)

The PHP parser had a bug here in that it presumed JSON encoding would
succeed (and there are reasons it might not). This checks the return
value of `json_encode` and emits a relevant error message if
appropriate. Before this, a triggering case would result in empty output
and an unhelpful error message from `JSON.parse` upstream in the Ruby
code.
@wfleming wfleming force-pushed the will/json-octet-error branch from 4ee50f4 to 6577ca1 Compare January 4, 2016 18:51
wfleming added a commit that referenced this pull request Jan 4, 2016
@wfleming wfleming merged commit b618b82 into master Jan 4, 2016
@wfleming wfleming deleted the will/json-octet-error branch January 4, 2016 18:58
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants