Skip to content

Handle invalid collection getKey return values - #1008

Merged
KyleAMathews merged 2 commits into
mainfrom
claude/collection-getkey-validation-01Lt6qVNAFjPuGL2MrzeESNW
Dec 12, 2025
Merged

Handle invalid collection getKey return values#1008
KyleAMathews merged 2 commits into
mainfrom
claude/collection-getkey-validation-01Lt6qVNAFjPuGL2MrzeESNW

Conversation

@KyleAMathews

Copy link
Copy Markdown
Collaborator

Throws InvalidKeyError when getKey returns values other than string or number (e.g., null, objects, booleans). The validation is optimized to only require 1 typeof check on the happy path (string keys).

  • Add InvalidKeyError class to errors.ts
  • Update generateGlobalKey to validate key type before generating key
  • Add tests for invalid key types (null, object, boolean)
  • Add tests confirming valid keys (string, number, empty string, zero)

🎯 Changes

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with pnpm test:pr.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

Loading
Sign up for freeto 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.

3 participants

@KyleAMathews@samwillis@claude