Skip to content

fix: Validation raises TypeError when invalid JSON comes - #8153

Merged
kenjis merged 5 commits into
codeigniter4:developfrom
kenjis:fix-IncomingRequest-getJSON
Nov 18, 2023
Merged

kenjis merged 5 commits into
codeigniter4:developfrom
kenjis:fix-IncomingRequest-getJSON

Conversation

@kenjis

@kenjis kenjis commented Nov 5, 2023

Copy link
Copy Markdown
Member

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

@michalsn michalsn left a comment

Copy link
Copy Markdown
Member

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

kenjis commented Nov 6, 2023

Copy link
Copy Markdown
Member Author

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

kenjis commented Nov 7, 2023

Copy link
Copy Markdown
Member Author

I sent #8161

Comment thread system/HTTP/IncomingRequest.php
Comment thread tests/system/Validation/ValidationTest.php
@kenjis
kenjis force-pushed the fix-IncomingRequest-getJSON branch from 76c53c6 to bfcae8d Compare November 8, 2023 02:44
@kenjis

kenjis commented Nov 8, 2023

Copy link
Copy Markdown
Member Author

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 requested a review from MGatner November 10, 2023 23:01
@kenjis
kenjis merged commit 7160f66 into codeigniter4:develop Nov 18, 2023
@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