Skip to content

Conversation

@jnsdls
Copy link
Member

@jnsdls jnsdls commented Sep 12, 2025

TL;DR

Added error handling to ENS resolution functions to prevent unhandled promise rejections.

What changed?

Modified the resolveEns function to catch errors when resolving ENS names and addresses. Now, both resolveName and resolveAddress function calls include .catch(() => null) to gracefully handle failures by returning null instead of throwing exceptions.

How to test?

  1. Test ENS resolution with valid addresses and ENS names
  2. Test with invalid or non-existent ENS names to verify it returns null instead of throwing errors
  3. Verify that the application continues to function when ENS resolution fails

Why make this change?

This change improves error handling in the ENS resolution process, preventing unhandled promise rejections that could crash the application. By gracefully handling resolution failures, the application can continue to function even when ENS lookups fail, providing a more robust user experience.


PR-Codex overview

This PR focuses on modifying the handling of NFT ownership and improving error handling in ENS resolution.

Detailed summary

  • In getNFT.test.ts, the owner property of an NFT is changed from a specific address to null.
  • In ens.ts, error handling is updated:
    • An error is no longer thrown for an invalid ENS name; instead, it returns an object with address and ensName set to null.
    • The promise in resolveAddress is now caught and returns null on failure.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Summary by CodeRabbit

  • New Features
    • ENS lookups now gracefully handle failures and invalid inputs, returning empty values instead of throwing errors.
  • Bug Fixes
    • Prevented crashes during ENS resolution; results now consistently return address and name as null when unavailable.
    • NFT fetches may show owner as null when ownership can’t be resolved, avoiding misleading data.
  • Tests
    • Updated snapshot for ERC-721 read to reflect null owner in indexer-based retrieval.

@changeset-bot
Copy link

changeset-bot bot commented Sep 12, 2025

⚠️ No Changeset found

Latest commit: 67a701c

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

@vercel
Copy link

vercel bot commented Sep 12, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
docs-v2 Ready Ready Preview Comment Sep 13, 2025 0:32am
nebula Ready Ready Preview Comment Sep 13, 2025 0:32am
thirdweb_playground Ready Ready Preview Comment Sep 13, 2025 0:32am
thirdweb-www Ready Ready Preview Comment Sep 13, 2025 0:32am
wallet-ui Ready Ready Preview Comment Sep 13, 2025 0:32am

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 12, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Error handling in ENS resolution was changed to return nulls instead of throwing. A related ERC721 test snapshot was updated to reflect a null owner value while keeping the structure intact.

Changes

Cohort / File(s) Summary of Changes
ENS resolution error handling
apps/dashboard/src/@/lib/ens.ts
Wrapped resolveName and resolveAddress with catch handlers to return nulls on failure; resolveEns now consistently returns { address, ensName } with nulls when invalid or unresolved. No public API signature changes.
ERC721 test snapshot update
packages/thirdweb/src/extensions/erc721/read/getNFT.test.ts
Updated inline snapshot: owner field changed from a specific address to null in the "with owner using indexer" test; no other test logic or signatures changed.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Caller
  participant ENS as resolveEns
  participant Prov as Provider

  Caller->>ENS: resolveEns(input)
  alt input is ENS name
    ENS->>Prov: resolveName(input)
    Note over ENS,Prov: Errors caught → null
    Prov-->>ENS: address or null
    ENS->>Prov: resolveAddress(address)
    Note over ENS,Prov: Errors caught → null
    Prov-->>ENS: ensName or null
    ENS-->>Caller: { address, ensName }
  else input is address
    ENS->>Prov: resolveAddress(input)
    Note over ENS,Prov: Errors caught → null
    Prov-->>ENS: ensName or null
    ENS-->>Caller: { address: input or null, ensName }
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch Handle_ENS_resolution_errors_gracefully

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 70e5218 and 67a701c.

📒 Files selected for processing (2)
  • apps/dashboard/src/@/lib/ens.ts (1 hunks)
  • packages/thirdweb/src/extensions/erc721/read/getNFT.test.ts (1 hunks)

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added the Dashboard Involves changes to the Dashboard. label Sep 12, 2025
@jnsdls jnsdls marked this pull request as ready for review September 12, 2025 23:34
@jnsdls jnsdls requested review from a team as code owners September 12, 2025 23:34
Copy link
Member Author

jnsdls commented Sep 12, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • merge-queue - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@jnsdls jnsdls force-pushed the Add_tier6_for_SMS_country_pricing branch from 838ce8a to 4d05df2 Compare September 12, 2025 23:35
@jnsdls jnsdls force-pushed the Handle_ENS_resolution_errors_gracefully branch from 1f9ab75 to 6e6b8f4 Compare September 12, 2025 23:35
@vercel vercel bot temporarily deployed to Preview – nebula September 12, 2025 23:35 Inactive
@vercel vercel bot temporarily deployed to Preview – docs-v2 September 12, 2025 23:35 Inactive
@vercel vercel bot temporarily deployed to Preview – wallet-ui September 12, 2025 23:35 Inactive
@vercel vercel bot temporarily deployed to Preview – thirdweb_playground September 12, 2025 23:35 Inactive
@jnsdls jnsdls force-pushed the Handle_ENS_resolution_errors_gracefully branch from 6e6b8f4 to fbf1fa3 Compare September 12, 2025 23:40
@vercel vercel bot temporarily deployed to Preview – wallet-ui September 12, 2025 23:40 Inactive
@vercel vercel bot temporarily deployed to Preview – docs-v2 September 12, 2025 23:40 Inactive
@vercel vercel bot temporarily deployed to Preview – nebula September 12, 2025 23:40 Inactive
@vercel vercel bot temporarily deployed to Preview – thirdweb_playground September 12, 2025 23:40 Inactive
@github-actions
Copy link
Contributor

github-actions bot commented Sep 12, 2025

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 63.96 KB (0%) 1.3 s (0%) 169 ms (+189.88% 🔺) 1.5 s
thirdweb (cjs) 356.86 KB (0%) 7.2 s (0%) 560 ms (+16.1% 🔺) 7.7 s
thirdweb (minimal + tree-shaking) 5.73 KB (0%) 115 ms (0%) 66 ms (+2122.25% 🔺) 181 ms
thirdweb/chains (tree-shaking) 526 B (0%) 11 ms (0%) 40 ms (+1156.1% 🔺) 51 ms
thirdweb/react (minimal + tree-shaking) 19.15 KB (0%) 383 ms (0%) 76 ms (+2911.97% 🔺) 459 ms

@jnsdls jnsdls force-pushed the Handle_ENS_resolution_errors_gracefully branch from fbf1fa3 to f745905 Compare September 12, 2025 23:51
@github-actions github-actions bot added packages SDK Involves changes to the thirdweb SDK labels Sep 12, 2025
Base automatically changed from Add_tier6_for_SMS_country_pricing to main September 12, 2025 23:51
@jnsdls jnsdls force-pushed the Handle_ENS_resolution_errors_gracefully branch from f745905 to 67a701c Compare September 12, 2025 23:52
@jnsdls jnsdls merged commit 8b8dfd9 into main Sep 12, 2025
7 of 13 checks passed
@jnsdls jnsdls deleted the Handle_ENS_resolution_errors_gracefully branch September 12, 2025 23:52
@codecov
Copy link

codecov bot commented Sep 12, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 56.63%. Comparing base (c82b606) to head (67a701c).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8045      +/-   ##
==========================================
- Coverage   56.64%   56.63%   -0.01%     
==========================================
  Files         904      904              
  Lines       58755    58755              
  Branches     4170     4166       -4     
==========================================
- Hits        33280    33275       -5     
- Misses      25369    25374       +5     
  Partials      106      106              
Flag Coverage Δ
packages 56.63% <ø> (-0.01%) ⬇️
see 2 files with indirect coverage changes
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Labels

Dashboard Involves changes to the Dashboard. packages SDK Involves changes to the thirdweb SDK

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants