fix(caip): add input validation to createCaip10AccountId#67
fix(caip): add input validation to createCaip10AccountId#67ak68a wants to merge 2 commits intoagentcommercekit:mainfrom
Conversation
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
WalkthroughAdded runtime input validation to Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 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 |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/caip/src/caips/caip-10.ts`:
- Around line 41-46: Add explicit string type guards before using
caip2ChainIdRegex.test(chainId) and caip10AccountAddressRegex.test(address):
check typeof chainId === "string" and typeof address === "string" and throw the
existing Error messages if those checks fail, then perform the regex tests as
currently written; update the validation logic around the caip2ChainIdRegex and
caip10AccountAddressRegex usages so non-string inputs are rejected early and
clearly (refer to the variables chainId, address and the regex constants
caip2ChainIdRegex, caip10AccountAddressRegex).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: efc6a196-ca87-46a2-a4ff-64f44f7a18df
📒 Files selected for processing (2)
packages/caip/src/caips/caip-10.test.tspackages/caip/src/caips/caip-10.ts
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
chainIdagainstcaip2ChainIdRegexandaddressagainstcaip10AccountAddressRegexbefore creating the account IDcreateCaip10AccountIdpreviously performed no validation, allowing malformed chain IDs and addresses to propagate silently. The regex patterns were already defined in the module but not being used. This brings the function in line withcaip10Parts(), which already validates its input.Test plan
AI Disclosure: This PR was developed with assistance from Claude Code (Claude Opus).
Summary by CodeRabbit