Repository navigation
fix: return false for nonexistent locations in utils/json-pointer/has - #16779
Planeshifter wants to merge 3 commits into
Conversation
…has` The job `Node.js v16` on workflow `linux_test` failed on develop with `TypeError: Cannot read properties of undefined (reading 'key')` in `utils/json-pointer/has`. Root cause: `utils/json-pointer/resolve` now returns `undefined` for nonexistent properties, out-of-bounds indices, and non-traversable values instead of throwing, but `has` only guarded against thrown errors and dereferenced the result unconditionally. This commit returns `false` when `resolve` returns `undefined`, restoring the documented behavior for nonexistent pointers. Ref: https://github.com/stdlib-js/stdlib/actions/runs/45006112520 Ref: #16676 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017wWD7AnSiKVdbmtrLsPBRs
Coverage Report
The above coverage report was generated for the changes in this PR. |
|
@gururaj1512 Mind reviewing this PR? It is possible further changes need to be made (e.g., to tests, etc). If so, you may want to take over this PR. |
|
Two
For Generated by Claude Code |
|
I opened a new PR #16779 because the package needs to be refactored into a standalone package rather than relying on |
Description
This pull request:
utils/json-pointer/hasthrowingTypeError: Cannot read properties of undefined (reading 'key')for any pointer which does not resolve to an existing location (e.g.,has( { 'foo': 'bar' }, '/missing' ), the README example).Failing run: https://github.com/stdlib-js/stdlib/actions/runs/45006112520 (
linux_test,Node.js v16). The same failure occurred on the 2026-11-21 scheduled run.Root cause: #16676 changed
utils/json-pointer/resolveto returnundefinedfor nonexistent locations instead of throwing.hasonly guarded against thrown errors and dereferenced the result unconditionally. The fix returnsfalsewhenresolvereturnsundefined. Thetry/catchremains, asresolvestill throws for invalid arguments, malformed pointers, and unsafe tokens.Related Issues
This pull request has the following related issues:
undefinedfor nonexistent document locations #16676Reference Packages
This pull request followed these packages:
Questions
No.
Other
utils/json-pointer/gethas the same regression (return resolve( document, pointer ).value;). Its testthrows an error when provided out-of-bounds array indicesnow fails (expectsRangeError, receivesTypeError), and its@throwsannotations no longer hold. It was masked in CI by thehascrash. Left out of this PR, as it requires deciding whethergetshould throw or returnundefined.linux_testwill likely remain red untilgetis addressed.Locally (Node 22):
hastests 45/45,resolvetests 84/84.Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
This PR was written primarily by Claude Code as part of an automated CI failure triage routine.
@stdlib-js/reviewersGenerated by Claude Code