Skip to content

Conversation

@jnsdls
Copy link
Member

@jnsdls jnsdls commented Oct 24, 2025

[SDK] Fix: Filter out null-ish values from ERC721 and ERC1155 getNFTs() arrays

Notes for the reviewer

This PR adds filtering to ensure that only NFTs with valid IDs are returned from the getNFTs() methods in both ERC721 and ERC1155 extensions. The change applies to results from both indexer and RPC data sources.

How to test

Verify that ERC721.getNFTs() and ERC1155.getNFTs() no longer return null or undefined values in their result arrays.

Summary by CodeRabbit

  • Bug Fixes
    • Improved NFT data reliability for ERC721 and ERC1155 by filtering out null/undefined entries across all retrieval methods and fallback paths, ensuring returned lists include only NFTs with defined IDs. This prevents incomplete items from appearing and improves consistency across indexer and RPC sources, reducing unexpected missing data and improving downstream display and handling.

PR-Codex overview

This PR focuses on filtering out nullish values from the arrays returned by the ERC721.getNFTs() and ERC1155.getNFTs() methods to ensure only valid NFT objects are processed.

Detailed summary

  • Added filtering for nullish values in the ERC721.getNFTs() method.
  • Added filtering for nullish values in the ERC1155.getNFTs() method.
  • Updated the handling of getNFTsFromInsight and getNFTsFromRPC to include the filtering logic.

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

@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 9:47pm
nebula Ready Ready Preview Comment Oct 24, 2025 9:47pm
thirdweb_playground Ready Ready Preview Comment Oct 24, 2025 9:47pm
thirdweb-www Ready Ready Preview Comment Oct 24, 2025 9:47pm
wallet-ui Ready Ready Preview Comment Oct 24, 2025 9:47pm

@changeset-bot
Copy link

changeset-bot bot commented Oct 24, 2025

🦋 Changeset detected

Latest commit: e3d11eb

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
thirdweb Patch
@thirdweb-dev/nebula Patch
@thirdweb-dev/wagmi-adapter Patch
wagmi-inapp Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

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.

@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

Adds filtering logic to remove NFTs with undefined or null id values from the returned arrays in ERC721 and ERC1155 getNFTs() functions across all retrieval paths (Insight, RPC, and fallback).

Changes

Cohort / File(s) Summary
Changeset metadata
\.changeset/good-regions-dig.md
Documents the change to filter null-ish values from ERC721 and ERC1155 getNFTs() arrays
NFT retrieval filtering
packages/thirdweb/src/extensions/erc721/read/getNFTs.ts, packages/thirdweb/src/extensions/erc1155/read/getNFTs.ts
Adds .filter() to remove NFTs lacking an id field across all code paths: Insight retrieval, RPC retrieval, and RPC fallback path when indexer is disabled

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Verify filter logic correctly targets NFTs with undefined/null id values
  • Confirm filtering is consistently applied across all return paths in both files
  • Check that no unintended side effects from removing entries from the result arrays

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The PR title "Filter out null-ish values from ERC721 and ERC1155 getNFTs() arrays" directly and accurately describes the main change in the pull request. According to the raw summary, the changes add filtering to both ERC721.getNFTs() and ERC1155.getNFTs() methods to exclude null or undefined values. The title is concise, specific, and clearly communicates the primary objective without vague terminology or noise. A teammate scanning the repository history would immediately understand the purpose of this change.
Description Check ✅ Passed The PR description follows the required template structure and includes all the essential sections. It contains a properly formatted title with the "[SDK] Fix:" prefix, a "Notes for the reviewer" section that explains the change clearly, and a "How to test" section with specific testing instructions. The description is substantive and not generic, explaining that the filtering applies to both indexer and RPC data sources. While the Linear issue tag in the format TEAM-0000 is not explicitly included, this is a minor omission given that the other critical sections are well-documented and complete.
✨ 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 Filter_out_null-ish_values_from_ERC721_and_ERC1155_getNFTs_arrays

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

@jnsdls jnsdls marked this pull request as ready for review October 24, 2025 21:22
@jnsdls jnsdls requested review from a team as code owners October 24, 2025 21:22
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 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 46b9d2d and f4d9b9b.

📒 Files selected for processing (3)
  • .changeset/good-regions-dig.md (1 hunks)
  • packages/thirdweb/src/extensions/erc1155/read/getNFTs.ts (1 hunks)
  • packages/thirdweb/src/extensions/erc721/read/getNFTs.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{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/getNFTs.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/getNFTs.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/getNFTs.ts
  • packages/thirdweb/src/extensions/erc721/read/getNFTs.ts
.changeset/*.md

📄 CodeRabbit inference engine (AGENTS.md)

.changeset/*.md: Each change in packages/* must include a changeset for the appropriate package
Version bump rules: patch for non‑API changes; minor for new/modified public API

Files:

  • .changeset/good-regions-dig.md
⏰ 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). (7)
  • GitHub Check: E2E Tests (pnpm, esbuild)
  • GitHub Check: E2E Tests (pnpm, webpack)
  • GitHub Check: E2E Tests (pnpm, vite)
  • GitHub Check: Build Packages
  • GitHub Check: Size
  • GitHub Check: Lint Packages
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (1)
.changeset/good-regions-dig.md (1)

1-5: LGTM! Changeset version bump is appropriate.

The patch version bump is correct for this defensive change that filters out null-ish values. The description accurately reflects the changes.

@jnsdls jnsdls force-pushed the Filter_out_null-ish_values_from_ERC721_and_ERC1155_getNFTs_arrays branch from f4d9b9b to e3d11eb Compare October 24, 2025 21:27
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

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

74-85: Critical issue resolved: Token ID 0 is now correctly handled.

The filter logic correctly excludes NFTs with null or undefined ids while preserving valid token ID 0 (whether 0, 0n, or "0x0"). The explicit null and undefined checks address the previous critical issue where a truthy check would have incorrectly removed NFTs with ID 0.

Optional: Simplify using idiomatic null check.

The expression nft?.id !== undefined && nft?.id !== null can be simplified to nft?.id != null (using loose equality !=). In JavaScript/TypeScript, x != null is equivalent to x !== null && x !== undefined and is the idiomatic way to check for null-ish values.

Apply this diff for a more concise expression:

-      return await getNFTsFromInsight(options).then((nfts) =>
-        nfts.filter((nft) => nft?.id !== undefined && nft?.id !== null),
-      );
+      return await getNFTsFromInsight(options).then((nfts) =>
+        nfts.filter((nft) => nft?.id != null),
+      );
     } catch {
-      return await getNFTsFromRPC(options).then((nfts) =>
-        nfts.filter((nft) => nft?.id !== undefined && nft?.id !== null),
-      );
+      return await getNFTsFromRPC(options).then((nfts) =>
+        nfts.filter((nft) => nft?.id != null),
+      );
     }
   }
-  return await getNFTsFromRPC(options).then((nfts) =>
-    nfts.filter((nft) => nft?.id !== undefined && nft?.id !== null),
-  );
+  return await getNFTsFromRPC(options).then((nfts) =>
+    nfts.filter((nft) => nft?.id != null),
+  );
📜 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 f4d9b9b and e3d11eb.

📒 Files selected for processing (3)
  • .changeset/good-regions-dig.md (1 hunks)
  • packages/thirdweb/src/extensions/erc1155/read/getNFTs.ts (1 hunks)
  • packages/thirdweb/src/extensions/erc721/read/getNFTs.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • .changeset/good-regions-dig.md
  • packages/thirdweb/src/extensions/erc1155/read/getNFTs.ts
🧰 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/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/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/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). (8)
  • GitHub Check: E2E Tests (pnpm, esbuild)
  • GitHub Check: E2E Tests (pnpm, vite)
  • GitHub Check: E2E Tests (pnpm, webpack)
  • GitHub Check: Size
  • GitHub Check: Build Packages
  • GitHub Check: Lint Packages
  • GitHub Check: Unit Tests
  • GitHub Check: Analyze (javascript)

@codecov
Copy link

codecov bot commented Oct 24, 2025

Codecov Report

❌ Patch coverage is 77.77778% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 54.90%. Comparing base (46b9d2d) to head (e3d11eb).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...es/thirdweb/src/extensions/erc1155/read/getNFTs.ts 55.55% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8311      +/-   ##
==========================================
- Coverage   54.90%   54.90%   -0.01%     
==========================================
  Files         919      919              
  Lines       60675    60687      +12     
  Branches     4126     4135       +9     
==========================================
+ Hits        33315    33319       +4     
- Misses      27259    27267       +8     
  Partials      101      101              
Flag Coverage Δ
packages 54.90% <77.77%> (-0.01%) ⬇️
Files with missing lines Coverage Δ
...ges/thirdweb/src/extensions/erc721/read/getNFTs.ts 87.17% <100.00%> (+0.69%) ⬆️
...es/thirdweb/src/extensions/erc1155/read/getNFTs.ts 77.21% <55.55%> (-2.24%) ⬇️

... and 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.

@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%) 258 ms (+50.83% 🔺) 1.6 s
thirdweb (cjs) 365.82 KB (0%) 7.4 s (0%) 1.6 s (+1.64% 🔺) 8.9 s
thirdweb (minimal + tree-shaking) 5.73 KB (0%) 115 ms (0%) 97 ms (+1403.12% 🔺) 212 ms
thirdweb/chains (tree-shaking) 526 B (0%) 11 ms (0%) 73 ms (+2353.07% 🔺) 83 ms
thirdweb/react (minimal + tree-shaking) 19.09 KB (0%) 382 ms (0%) 54 ms (+290.24% 🔺) 436 ms

@jnsdls jnsdls merged commit bfd3be7 into main Oct 24, 2025
20 of 24 checks passed
@jnsdls jnsdls deleted the Filter_out_null-ish_values_from_ERC721_and_ERC1155_getNFTs_arrays branch October 24, 2025 21:39
@joaquim-verges joaquim-verges mentioned this pull request Oct 24, 2025
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.

2 participants