Skip to content

🧪 Add edge case test for string error-codes in Response#609

Merged
rowan-m merged 1 commit intomainfrom
test/edge-case-string-error-codes-3535967434115694764
Mar 25, 2026
Merged

🧪 Add edge case test for string error-codes in Response#609
rowan-m merged 1 commit intomainfrom
test/edge-case-string-error-codes-3535967434115694764

Conversation

@rowan-m
Copy link
Contributor

@rowan-m rowan-m commented Mar 25, 2026

🎯 What: The testing gap addressed
A missing edge case test for the Response class when error-codes are passed as a string (e.g., {"success": false, "error-codes": "bad-request"}) instead of the expected array format.

📊 Coverage: What scenarios are now tested
The ResponseTest::testFromJson method now includes a scenario that verifies handling of string error-codes in the JSON response. If error-codes is not an array, the parser falls back to returning an array containing ReCaptcha::E_UNKNOWN_ERROR, maintaining correct expected types.

Result: The improvement in test coverage
The test coverage now protects the explicit is_array($responseData['error-codes']) type safety check in Response::fromJson. It guarantees the code safely ignores invalid formats and handles the error gracefully without throwing type errors downstream.


PR created automatically by Jules for task 3535967434115694764 started by @rowan-m

Added a new test case to `ResponseTest::provideJson` that ensures
the `Response::fromJson` method handles invalid string `error-codes`
by defaulting to `[ReCaptcha::E_UNKNOWN_ERROR]`.

Co-authored-by: rowan-m <108052+rowan-m@users.noreply.github.com>
@google-labs-jules
Copy link
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@coveralls
Copy link

Coverage Status

coverage: 100.0%. remained the same
when pulling 5424a3b on test/edge-case-string-error-codes-3535967434115694764
into 188ef61 on main.

@rowan-m rowan-m merged commit 0c1aee9 into main Mar 25, 2026
7 checks passed
@rowan-m rowan-m deleted the test/edge-case-string-error-codes-3535967434115694764 branch March 25, 2026 11:14
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