Skip to content

fix(cli): add robust input validation for Ethereum address identifiers#1814

Open
sethoshi18 wants to merge 2 commits into
xmtp:mainfrom
sethoshi18:fix/cli-identifier-validation-14067937858810210352
Open

fix(cli): add robust input validation for Ethereum address identifiers#1814
sethoshi18 wants to merge 2 commits into
xmtp:mainfrom
sethoshi18:fix/cli-identifier-validation-14067937858810210352

Conversation

@sethoshi18

@sethoshi18 sethoshi18 commented May 26, 2026

Copy link
Copy Markdown

Add validateIdentifier utility in the CLI using viem's isAddress to ensure Ethereum addresses are structurally sound before passing them to the SDK. This prevents the CLI from making unnecessary network calls or encountering confusing downstream C++ binding errors when given malformed input.

Applied validation symmetrically across the following commands:

  • client change-recovery-identifier
  • client inbox-id
  • client remove-account
  • conversation add-members
  • conversation remove-members
  • conversations create-dm
  • conversations create-group

Includes an offline unit test for create-dm to verify the fast-failure path.

Note

Add Ethereum address validation to CLI commands before execution

  • Adds a validateIdentifier utility in utils/client.ts that uses viem's isAddress to throw on invalid Ethereum addresses.
  • Applies validation in 7 commands (change-recovery-identifier, inbox-id, remove-account, add-members, remove-members, create-dm, create-group) so invalid addresses are rejected before any network call or confirmation prompt.
  • Adds a test in the create-dm suite asserting the command fails with an 'Invalid Ethereum address' message.

Macroscope summarized 823b8f3.

Add `validateIdentifier` utility in the CLI using viem's `isAddress` to ensure
Ethereum addresses are structurally sound before passing them to the SDK.
This prevents the CLI from making unnecessary network calls or encountering
confusing downstream C++ binding errors when given malformed input.

Applied validation symmetrically across the following commands:
- `client change-recovery-identifier`
- `client inbox-id`
- `client remove-account`
- `conversation add-members`
- `conversation remove-members`
- `conversations create-dm`
- `conversations create-group`

Includes an offline unit test for `create-dm` to verify the fast-failure path.
@sethoshi18 sethoshi18 requested a review from a team as a code owner May 26, 2026 18:37
@changeset-bot

changeset-bot Bot commented May 26, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 823b8f3

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Add `validateIdentifier` utility in the CLI using viem's `isAddress` to ensure
Ethereum addresses are structurally sound before passing them to the SDK.
This prevents the CLI from making unnecessary network calls or encountering
confusing downstream C++ binding errors when given malformed input.

Applied validation symmetrically across the following commands:
- `client change-recovery-identifier`
- `client inbox-id`
- `client remove-account`
- `conversation add-members`
- `conversation remove-members`
- `conversations create-dm`
- `conversations create-group`

Includes an offline unit test for `create-dm` to verify the fast-failure path.
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.

1 participant