Skip to content

resolveDecryptedValue is not wrapped in try/catch #66

Description

@manuelwedler

Problem

All ExternalDataProvider methods are supplied by the wallet and can throw (network errors, rejected signatures, bugs). Every call site in src/formatters.ts wraps the provider call in try/catch and falls back to a warning:

  • resolveChainInfo (formatters.ts:171, :271, :798)
  • resolveToken (formatters.ts:296, :1161)
  • resolveNftCollectionName (formatters.ts:498)
  • resolveBlockTimestamp (formatters.ts:587)
  • resolveLocalName / resolveEnsName (formatters.ts:1039, :1058)

The one exception is resolveDecryptedValue in decryptFieldValue (src/fields.ts:972). The call is not wrapped. If the wallet callback throws, the error goes up through processSingleField and the whole format() call rejects. Only the later hexToBytes(result.value) has a try.

Expected behavior

Catch a thrown error from resolveDecryptedValue and return a DECRYPTION_FAILED warning, consistent with the other handlers. The field then renders the fallbackLabel / [Encrypted] placeholder with rawEncryptedValue set.

Tasks

  • Wrap the resolveDecryptedValue call in src/fields.ts in try/catch and map a throw to DECRYPTION_FAILED.
  • Add a test in test/registry-cases/zama/zama.spec.ts for a provider that throws.
  • Update CLAUDE.md: document that every ExternalDataProvider call must be wrapped in try/catch because the methods are user-provided and can throw; a throw must become a warning, never a rejected format() call. Add the throw case to the DECRYPTION_FAILED list in the Encrypted Fields section.
  • Check GUIDE.md and DECRYPTION.md for statements about error handling of provider methods.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions