Skip to content

fix: return false for nonexistent locations in utils/json-pointer/has - #16779

Open
Planeshifter wants to merge 3 commits into
developfrom
philipp/ci-fix-linux-test-json-pointer-has-2026-11-22
Open

Planeshifter wants to merge 3 commits into
developfrom
philipp/ci-fix-linux-test-json-pointer-has-2026-11-22

Conversation

@Planeshifter

Copy link
Copy Markdown
Member

Description

What is the purpose of this pull request?

This pull request:

  • fixes utils/json-pointer/has throwing TypeError: 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/resolve to return undefined for nonexistent locations instead of throwing. has only guarded against thrown errors and dereferenced the result unconditionally. The fix returns false when resolve returns undefined. The try/catch remains, as resolve still throws for invalid arguments, malformed pointers, and unsafe tokens.

Related Issues

Does this pull request have any related issues?

This pull request has the following related issues:

Reference Packages

Did the content of this pull request follow one or more existing packages? Answering is optional.

This pull request followed these packages:

  • none

Questions

Any questions for reviewers of this pull request?

No.

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

utils/json-pointer/get has the same regression (return resolve( document, pointer ).value;). Its test throws an error when provided out-of-bounds array indices now fails (expects RangeError, receives TypeError), and its @throws annotations no longer hold. It was masked in CI by the has crash. Left out of this PR, as it requires deciding whether get should throw or return undefined. linux_test will likely remain red until get is addressed.

Locally (Node 22): has tests 45/45, resolve tests 84/84.

Checklist

Please ensure the following tasks are completed before submitting this pull request.

AI Assistance

When authoring the changes proposed in this PR, did you use any kind of AI assistance?

  • Yes
  • No

If you answered "yes" above, how did you use AI assistance?

  • Code generation (e.g., when writing an implementation or fixing a bug)
  • Test/benchmark generation
  • Documentation (including examples)
  • Research and understanding

Disclosure

If you answered "yes" to using AI assistance, please provide a short disclosure indicating how you used AI assistance. This helps reviewers determine how much scrutiny to apply when reviewing your contribution. Example disclosures: "This PR was written primarily by Claude Code." or "I consulted ChatGPT to understand the codebase, but the proposed changes were fully authored manually by myself.".

This PR was written primarily by Claude Code as part of an automated CI failure triage routine.


@stdlib-js/reviewers


Generated by Claude Code

…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
@stdlib-bot

stdlib-bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
utils/json-pointer/has $\\color{green}128/128$
$\\color{green}+0.00\\%$
$\\color{green}9/9$
$\\color{green}+0.00\\%$
$\\color{green}1/1$
$\\color{green}+0.00\\%$
$\\color{green}128/128$
$\\color{green}+0.00\\%$

The above coverage report was generated for the changes in this PR.

@kgryte
kgryte requested a review from gururaj1512 November 27, 2026 11:02
@kgryte

kgryte commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

@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.

@kgryte
kgryte marked this pull request as ready for review November 27, 2026 11:03
@kgryte
kgryte requested a review from a team November 27, 2026 11:03

Planeshifter commented Nov 27, 2026 •

Copy link
Copy Markdown
Member Author

Two push-triggered jobs on acafdd6c5 failed by timing out. Neither failure comes from this PR's diff:

For push events, these workflows diff github.event.before..github.event.after. Here that range is 19137494f..acafdd6c5, so the merge from develop brings every package changed on develop since 2026-11-22 into scope. The pull_request-triggered Run affected tests diffs against the merge base, covers only utils/json-pointer/has, and passed. Re-running either job would time out the same way.


Generated by Claude Code

@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Nov 27, 2026
@gururaj1512

Copy link
Copy Markdown
Member

I opened a new PR #16779 because the package needs to be refactored into a standalone package rather than relying on resolve internally. This PR can be closed.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Review A pull request which needs code review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants