Skip to content

Conversation

@Gudahtt
Copy link
Member

@Gudahtt Gudahtt commented Oct 28, 2025

Explanation

Add a name property to PermissionController custom errors.

This fixes a bug recently introduced in @metamask/multichain-api-middleware. A recent PR (#6985) assumed these name proeprties were already present.

References

Fixes error in #6985

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed, highlighting breaking changes as necessary
  • I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes

Note

Adds a base CustomError to set name on PermissionController errors, updates affected error classes and tests, and updates related changelogs (including multichain API middleware fix note).

  • Permission Controller:
    • Errors: Introduce CustomError base that sets name; migrate multiple custom errors to extend it (e.g., InvalidSubjectIdentifierError, UnrecognizedSubjectError, Caveat* errors, etc.).
    • Tests: Add assertions for .name on CaveatMergeTypeMismatchError and EndowmentPermissionDoesNotExistError in src/errors.test.ts.
    • Docs: Update CHANGELOG.md with “Added” entry for error name property.
  • Multichain API Middleware:
    • Docs: Update CHANGELOG.md with “Fixed” entry for wallet_revokeSession error handling referencing changes in @metamask/permission-controller.

Written by Cursor Bugbot for commit 9b0e3ed. This will update automatically on new commits. Configure here.

Add a `name` property to `PermissionController` custom errors.

This fixes a bug recently introduced in `@metamask/multichain-api-middleware`.
A recent PR (#6985) assumed these `name` proeprties were already present.
Copy link
Member Author

Choose a reason for hiding this comment

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

We should revisit these tests at some point to cover all of the errors. I just added a test for the couple already tested for now.

@Gudahtt Gudahtt force-pushed the permission-controller-add-custom-error-names branch from f2d09eb to 9b0e3ed Compare October 28, 2025 20:41
@Gudahtt Gudahtt marked this pull request as ready for review October 28, 2025 20:41
@Gudahtt Gudahtt requested review from a team as code owners October 28, 2025 20:41
@Gudahtt Gudahtt enabled auto-merge (squash) October 28, 2025 20:44
@Gudahtt Gudahtt merged commit e8def69 into main Oct 28, 2025
257 checks passed
@Gudahtt Gudahtt deleted the permission-controller-add-custom-error-names branch October 28, 2025 20:45
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.

3 participants