fix: isJson assertion should accept arrays as valid JSON#7620
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThe Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
483554a to
2eba837
Compare
…ce test coverage - Modified the JSON validation logic to accept arrays as valid JSON objects. - Updated tests to ensure correct behavior for various array scenarios, including empty arrays and arrays of strings and objects.
2eba837 to
5301b71
Compare
… arrays - Updated the JSON validation to allow arrays as valid JSON objects, ensuring compatibility with various data structures. - Adjusted the test assertions to reflect the new validation criteria.
Description
JIRA
isJsonassertion to accept JSON arrays (e.g.["A55001213ZX0A"]), which were incorrectly rejectedContext
The
isJsonchai property explicitly excluded arrays with!Array.isArray(obj). This causedres.body: isJsonassertions to fail for API responses returning JSON arrays — a valid and common response format.Fixes #7556
Test plan
isJsontests updated and passingContribution Checklist:
Note: Keeping the PR small and focused helps make it easier to review and merge. If you have multiple changes you want to make, please consider submitting them as separate pull requests.
Publishing to New Package Managers
Please see here for more information.
Summary by CodeRabbit
Bug Fixes
isJsonassertion now treats arrays (including empty arrays, arrays of primitives, and arrays of objects) as valid JSON; previously it accepted only plain objects. Assertion behavior and error reporting remain unchanged.Tests