You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: validate avatar route boundary and thread branded input types
Close the second unvalidated boundary and make validation enforceable by
the compiler across the whole resolver call graph.
- Validate the GET /:type/:id avatar route inside parseQuery: the stripped,
lowercased id must be a valid address or handle (avatarIdSchema), else the
route returns HTTP 400 (InvalidQueryError) instead of a 500. The /clear
route gets the same 400 path. Size/width/height query clamping is unchanged.
- Add branded nominal types in src/helpers/validation.ts: addressSchema /
handleSchema now .brand() and export ValidatedAddress / ValidatedHandle, and
avatarIdSchema (ValidatedAddress | ValidatedHandle) for the avatar route. All
entry-point schemas (JSON-RPC + avatar route) output branded values.
- Thread the branded input types through the resolver entry points:
lookupAddresses / resolveNames, lookupDomains, getOwner, and the avatar
resolver entries (resolvers/ens, resolvers/basename, addressResolvers
basename getAvatar / castToEnsName). The compiler now enforces that only
validated values reach the resolvers. Plain Address / Handle aliases stay for
values flowing OUT of the resolvers (resolved network values are plain).
- Drop the now-redundant inner isAddress guard in lookupDomains (shape is
guaranteed by the branded Address at the only caller).
- Keep normalizeAddresses: its getAddress checksum / lowercase step is
NORMALIZATION (required for stable redis cache keys and dedup), not
validation, and its reject-filter still guards the unbranded clearCache
route param. Cache key shape is unchanged. The batch cap (max 50) stays as a
zod .max at the boundary since types cannot encode array length.
- Tests: add e2e cases asserting a bad avatar id returns 400 and valid
address / handle ids do not; brand integration test inputs via the real
schemas (test/helpers/validation.ts); convert the two lookupDomains
invalid-input tests to assert the boundary schema rejects them.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
0 commit comments