Skip to content

Conversation

@jnsdls
Copy link
Member

@jnsdls jnsdls commented Oct 24, 2025


PR-Codex overview

This PR focuses on improving the handling of metadata retrieval for ERC721 and ERC1155 NFTs. It ensures that a default metadata object is returned when metadata is null or undefined, and it simplifies the filtering of NFTs in the getNFTsFromInsight function.

Detailed summary

  • In getNFT.ts and getNFTs.ts, added logic to return a default metadata object if the fetched metadata is null or undefined.
  • Removed unnecessary filtering of NFTs based on id in getNFTsFromInsight and getNFTsFromRPC functions.
  • Improved error handling by maintaining the structure of the catch blocks.

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

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Improved handling of incomplete or missing NFT metadata for ERC1155 and ERC721 operations, now returning default values when metadata is unavailable.
    • Removed ID-based filtering that was excluding NFTs from results, improving data completeness and result accuracy.

@vercel
Copy link

vercel bot commented Oct 24, 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 Oct 24, 2025 10:36pm
nebula Ready Ready Preview Comment Oct 24, 2025 10:36pm
thirdweb_playground Ready Ready Preview Comment Oct 24, 2025 10:36pm
thirdweb-www Ready Ready Preview Comment Oct 24, 2025 10:36pm
wallet-ui Ready Ready Preview Comment Oct 24, 2025 10:36pm

@changeset-bot
Copy link

changeset-bot bot commented Oct 24, 2025

⚠️ No Changeset found

Latest commit: 068c9fb

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

@github-actions github-actions bot added packages SDK Involves changes to the thirdweb SDK labels Oct 24, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 24, 2025

Walkthrough

The changes systematically modify NFT reading functions in ERC1155 and ERC721 extensions. Metadata handling now explicitly checks for nullish values with .then() chaining and returns default objects. ID filtering logic that removed items with undefined or null ids after fetching from indexer/RPC sources has been removed across all affected functions.

Changes

Cohort / File(s) Summary
Metadata nullish handling
packages/thirdweb/src/extensions/erc1155/read/getNFT.ts, packages/thirdweb/src/extensions/erc721/read/getNFT.ts
After fetchTokenMetadata, added .then() chain to check if metadata is nullish and return default object (with id, type, uri); otherwise propagate actual metadata. Existing .catch() remains for error cases.
ID filtering removal
packages/thirdweb/src/extensions/erc1155/read/getNFTs.ts, packages/thirdweb/src/extensions/erc721/read/getNFTs.ts
Removed post-fetch filtering of results with undefined/null ids. Now returns raw arrays directly from getNFTsFromInsight() and getNFTsFromRPC() in all code paths (normal, error, and non-indexer).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10–15 minutes

  • Homogeneous pattern changes applied consistently across paired files (metadata and filtering)
  • Straightforward logic modifications without signature changes
  • Primary focus: verify implications of removing ID filters and confirm nullish metadata handling is intentional across all paths

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The PR description does not follow the expected template structure provided in the repository. The template specifies required sections including a formatted title "[SDK/Dashboard/Portal] Feature/Fix: ...", an issue tag reference, "Notes for the reviewer", and "How to test" guidance. Instead, the description consists entirely of auto-generated PR-Codex output with the template commented out and unfilled. While the PR-Codex content does provide useful information about what changed and the purpose of the changes, the structured sections from the template are completely absent, and the PR title itself does not follow the specified format either. This represents a departure from the repository's documentation standards.
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title Check ✅ Passed The PR title "Handle null metadata in ERC721 and ERC1155 getNFT functions" is clear and specific, directly addressing a significant part of the changeset. The title accurately describes the main modifications to the getNFT.ts files, which now include explicit handling for nullish metadata by returning default objects. While the title does not cover all changes in the PR (the removal of NFT ID filtering in getNFTs.ts files is not mentioned), it still constitutes a valid partial description of a real and substantial aspect of the changeset. The title is concise, readable, and would help a teammate understand the primary focus of the metadata handling improvements.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch Handle_null_metadata_in_ERC721_and_ERC1155_getNFT_functions

📜 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 bfd3be7 and 068c9fb.

📒 Files selected for processing (4)
  • packages/thirdweb/src/extensions/erc1155/read/getNFT.ts (1 hunks)
  • packages/thirdweb/src/extensions/erc1155/read/getNFTs.ts (1 hunks)
  • packages/thirdweb/src/extensions/erc721/read/getNFT.ts (1 hunks)
  • packages/thirdweb/src/extensions/erc721/read/getNFTs.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: Write idiomatic TypeScript with explicit function declarations and return types
Limit each file to one stateless, single-responsibility function for clarity
Re-use shared types from @/types or local types.ts barrels
Prefer type aliases over interface except for nominal shapes
Avoid any and unknown unless unavoidable; narrow generics when possible
Choose composition over inheritance; leverage utility types (Partial, Pick, etc.)
Comment only ambiguous logic; avoid restating TypeScript in prose

**/*.{ts,tsx}: Use explicit function declarations and explicit return types in TypeScript
Limit each file to one stateless, single‑responsibility function
Re‑use shared types from @/types where applicable
Prefer type aliases over interface except for nominal shapes
Avoid any and unknown unless unavoidable; narrow generics when possible
Prefer composition over inheritance; use utility types (Partial, Pick, etc.)
Lazy‑import optional features and avoid top‑level side‑effects to reduce bundle size

Files:

  • packages/thirdweb/src/extensions/erc1155/read/getNFT.ts
  • packages/thirdweb/src/extensions/erc1155/read/getNFTs.ts
  • packages/thirdweb/src/extensions/erc721/read/getNFT.ts
  • packages/thirdweb/src/extensions/erc721/read/getNFTs.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (CLAUDE.md)

Load heavy dependencies inside async paths to keep initial bundle lean (lazy loading)

Files:

  • packages/thirdweb/src/extensions/erc1155/read/getNFT.ts
  • packages/thirdweb/src/extensions/erc1155/read/getNFTs.ts
  • packages/thirdweb/src/extensions/erc721/read/getNFT.ts
  • packages/thirdweb/src/extensions/erc721/read/getNFTs.ts
packages/thirdweb/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

packages/thirdweb/**/*.{ts,tsx}: Every public symbol must have comprehensive TSDoc with at least one compiling @example and a custom tag (@beta, @internal, @experimental, etc.)
Comment only ambiguous logic; avoid restating TypeScript in prose
Lazy‑load heavy dependencies inside async paths (e.g., const { jsPDF } = await import("jspdf"))

Files:

  • packages/thirdweb/src/extensions/erc1155/read/getNFT.ts
  • packages/thirdweb/src/extensions/erc1155/read/getNFTs.ts
  • packages/thirdweb/src/extensions/erc721/read/getNFT.ts
  • packages/thirdweb/src/extensions/erc721/read/getNFTs.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: E2E Tests (pnpm, webpack)
  • GitHub Check: Size
  • GitHub Check: Unit Tests
  • GitHub Check: Build Packages
  • GitHub Check: Lint Packages
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (4)
packages/thirdweb/src/extensions/erc1155/read/getNFT.ts (1)

86-102: Nullish metadata handling improves robustness.

The explicit check for nullish metadata and default object return is a solid improvement. This ensures consistent NFT objects even when metadata fetch returns null or undefined, which prevents downstream parsing issues.

The error handling flow is preserved—both fetch errors and nullish results yield the same default structure with id, type, and uri.

packages/thirdweb/src/extensions/erc721/read/getNFT.ts (1)

142-158: LGTM! Good defensive handling of null metadata.

The explicit null-ish check in .then() ensures that parseNFT always receives a valid metadata object, even when fetchTokenMetadata succeeds but returns null or undefined. The default object structure is consistent with the error case in .catch() and earlier in the function.

packages/thirdweb/src/extensions/erc721/read/getNFTs.ts (1)

74-79: Verify that removing ID filtering is safe for insight API results.

Similar to the ERC1155 changes, the removal of NFT filtering means that any NFTs with undefined or null IDs from the insight API will now be included in results. The RPC fallback path should be safe since each call to getNFT with useIndexer: false will have an explicit tokenId (line 162). However, please verify that getContractNFTs (insight API) doesn't return NFTs with missing IDs.

Since the same insight API is used for both ERC721 and ERC1155, you can use the verification script from the ERC1155 getNFTs.ts review to check for ID validation patterns across the codebase.

packages/thirdweb/src/extensions/erc1155/read/getNFTs.ts (1)

55-60: Removal of ID filtering is safe—Insight API requires token_id as a mandatory field.

The Insight API contract guarantees that token_id is always present in NFT responses (it's a required field for the base response). Additionally, the RPC path derives token_id from an explicit loop counter, ensuring validity in both paths. The removal of filtering poses no risk to downstream consumers.

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • TEAM-0000: Entity not found: Issue - Could not find referenced Issue.

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

Copy link
Member Author

jnsdls commented Oct 24, 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 marked this pull request as ready for review October 24, 2025 22:08
@jnsdls jnsdls requested review from a team as code owners October 24, 2025 22:08
@github-actions
Copy link
Contributor

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 64.55 KB (0%) 1.3 s (0%) 196 ms (+146.76% 🔺) 1.5 s
thirdweb (cjs) 366.18 KB (+0.1% 🔺) 7.4 s (+0.1% 🔺) 756 ms (+7.41% 🔺) 8.1 s
thirdweb (minimal + tree-shaking) 5.73 KB (0%) 115 ms (0%) 89 ms (+2700.64% 🔺) 204 ms
thirdweb/chains (tree-shaking) 526 B (0%) 11 ms (0%) 62 ms (+3358.99% 🔺) 72 ms
thirdweb/react (minimal + tree-shaking) 19.09 KB (0%) 382 ms (0%) 84 ms (+2237.26% 🔺) 466 ms

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

Labels

packages SDK Involves changes to the thirdweb SDK

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants