Skip to content

fix(data): add early returns to storeItem and removeItem validation - #9250

Open
iUjjwalRaj wants to merge 1 commit into
processing:mainfrom
iUjjwalRaj:fix/store-item-validation-return
Open

iUjjwalRaj wants to merge 1 commit into
processing:mainfrom
iUjjwalRaj:fix/store-item-validation-return

Conversation

@iUjjwalRaj

Copy link
Copy Markdown

Summary

  • In src/data/local_storage.js, add missing return; statements to each validation branch in storeItem() (typeof key !== 'string', key.endsWith('p5TypeID'), and typeof value === 'undefined') and removeItem() (typeof key !== 'string').
  • Prevents execution from falling through into subsequent operations when invalid arguments are passed, avoiding uncaught TypeError: key.endsWith is not a function when a numeric key is passed, and preventing undefined values from being written to localStorage.
  • Add unit test suite storeItem and removeItem input validation in test/unit/data/local_storage.js verifying proper early return handling for non-string keys, invalid suffix keys, and undefined values.

Fixes #9242

Validation

  • npx vitest run test/unit/data/local_storage.js passed (21/21 unit tests).
  • npm run lint passed (0 errors).
  • git diff --check passed cleanly.

Copilot AI balanced review requested due to automatic review settings October 6, 2026 08:11
@welcome

welcome Bot commented Oct 6, 2026

Copy link
Copy Markdown

🎉 Thanks for opening this pull request! For guidance on contributing, check out our contributor guidelines and other resources for contributors!
🤔 Please ensure that your PR links to an issue, which has been approved for work by a maintainer; otherwise, there might already be someone working on it, or still ongoing discussion about implementation. You are welcome to join the discussion in an Issue if you're not sure!
🌸 Once your PR is merged, be sure to add yourself to the list of contributors on the readme page !

Thank You!

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@iUjjwalRaj
iUjjwalRaj force-pushed the fix/store-item-validation-return branch from 6101aed to edaff2e Compare October 7, 2026 08:18
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.

[p5.js 2.0+ Bug Report]: storeItem() validation branches are missing return, so bad input throws a TypeError or is stored anyway

2 participants