Skip to content

Fix handling of 422 responses where errors is a string - #1164

Merged
acrobat merged 1 commit into
KnpLabs:masterfrom
GrahamCampbell:fix-string-validation-errors
Aug 18, 2026
Merged

Fix handling of 422 responses where errors is a string#1164
acrobat merged 1 commit into
KnpLabs:masterfrom
GrahamCampbell:fix-string-validation-errors

Conversation

@GrahamCampbell

Copy link
Copy Markdown
Contributor

GitHub sometimes returns a 422 response in which the errors property is a plain string rather than an array of error objects, for example when creating a commit status for a commit that cannot be found. The exception thrower currently iterates over that property unconditionally, so instead of throwing a ValidationFailedException carrying the message from GitHub, it triggers a PHP warning about passing a string to foreach, which under most frameworks surfaces as an ErrorException and hides the real error. This change casts the property to an array before iterating, so a string is reported through the existing string handling branch, and adds a test case covering that response shape.

@acrobat
acrobat merged commit 123a064 into KnpLabs:master Aug 18, 2026
10 of 11 checks passed
@acrobat

acrobat commented Aug 18, 2026

Copy link
Copy Markdown
Collaborator

Thank you @GrahamCampbell

@acrobat

acrobat commented Aug 18, 2026

Copy link
Copy Markdown
Collaborator

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.

2 participants