fix: isJson assertion should accept arrays as valid JSON#7620
fix: isJson assertion should accept arrays as valid JSON#7620abhishek-bruno wants to merge 1 commit intousebruno:mainfrom
Conversation
|
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 (2)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughThe chai 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
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 and arrays of objects) as valid JSON; previously it only accepted plain objects.Tests