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

fix: Validation raises TypeError when invalid JSON comes #8153

Merged
merged 5 commits into from
Nov 18, 2023

Conversation

kenjis
Copy link
Member

@kenjis kenjis commented Nov 5, 2023

Needs #8161

Description
Fixes #8134

  • IncomingRequest will throw HTTPException when the body is invalid as JSON
  • add lang key HTTP.invalidJSON.

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@kenjis kenjis added the bug Verified issues on the current code behavior or pull requests that will fix them label Nov 5, 2023
@kenjis kenjis force-pushed the fix-IncomingRequest-getJSON branch from 0b926ea to 76c53c6 Compare November 6, 2023 01:14
Copy link
Member

@michalsn michalsn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like we need special treatment when the body is null.

@kenjis
Copy link
Member Author

kenjis commented Nov 6, 2023

How?

When is the body null?
https://github.com/codeigniter4/CodeIgniter4/blob/develop/system/HTTP/IncomingRequest.php#L153
Ah, when sending 0 or ''as body?

@kenjis kenjis marked this pull request as draft November 7, 2023 00:52
@kenjis
Copy link
Member Author

kenjis commented Nov 7, 2023

I sent #8161

@kenjis kenjis force-pushed the fix-IncomingRequest-getJSON branch from 76c53c6 to bfcae8d Compare November 8, 2023 02:44
@kenjis
Copy link
Member Author

kenjis commented Nov 8, 2023

Seems like we need special treatment when the body is null.

Done.

@kenjis kenjis marked this pull request as ready for review November 8, 2023 02:54
@kenjis kenjis merged commit 7160f66 into codeigniter4:develop Nov 18, 2023
62 checks passed
@kenjis kenjis deleted the fix-IncomingRequest-getJSON branch November 18, 2023 23:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified issues on the current code behavior or pull requests that will fix them
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error: Argument #2 ($array) must be of type array, null given - Validation.php
4 participants