Skip to content

[Insight] Make clientId optional and improve error handling #7158

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

joaquim-verges
Copy link
Member

@joaquim-verges joaquim-verges commented May 26, 2025


PR-Codex overview

This PR introduces several changes, primarily focusing on making the clientId optional in various configurations and enhancing the handling of large NFT collections during metadata updates. It also improves error handling in guest account generation and adds tests for batch transactions.

Detailed summary

  • Made clientId optional in EngineClientOptions and InsightClientOptions.
  • Updated headers to remove mandatory x-thirdweb-client-id.
  • Improved error handling in guest account generation.
  • Added a test for handling very large batches of NFTs in updateMetadata.test.ts.
  • Refactored updateMetadata.ts to process NFT metadata in smaller batches.

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

Summary by CodeRabbit

  • Bug Fixes
    • Improved error messages for guest authentication failures, now including detailed response information.
  • Tests
    • Added a new test suite to verify batching of transactions with in-app wallets using EIP-7702 execution mode.
    • Added a test to handle very large NFT batch metadata updates.
  • Chores
    • Made the client ID optional in configuration options.
    • Removed the client ID header from certain user status requests.
  • Performance Improvements
    • Enhanced NFT metadata fetching with batched requests and incremental validation to better handle large collections.

Copy link

vercel bot commented May 26, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 26, 2025 9:44pm
login ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 26, 2025 9:44pm
thirdweb_playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 26, 2025 9:44pm
thirdweb-www ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 26, 2025 9:44pm
wallet-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 26, 2025 9:44pm

Copy link

changeset-bot bot commented May 26, 2025

🦋 Changeset detected

Latest commit: 0831769

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

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
Contributor

coderabbitai bot commented May 26, 2025

Walkthrough

The updates include making the clientId property optional in both Insight and Engine client configurations, removing the client ID header from an enclave user status request, and enhancing error reporting in guest authentication. Additionally, a new test suite validates EIP-7702 minimal account batch transaction functionality, and NFT metadata update logic was optimized for large batches with a corresponding test added.

Changes

File(s) Change Summary
packages/insight/src/configure.ts, packages/engine/src/configure.ts Made clientId optional in the client options types.
packages/thirdweb/src/wallets/in-app/core/actions/get-enclave-user-status.ts Removed "x-thirdweb-client-id" header from the user status HTTP request.
packages/thirdweb/src/wallets/in-app/core/authentication/guest.ts Improved error handling to include HTTP status and response body in thrown errors.
packages/thirdweb/src/wallets/in-app/core/eip7702/minimal-account.test.ts Added a new test suite for EIP-7702 minimal account batch transaction functionality.
packages/thirdweb/src/extensions/erc721/drops/write/updateMetadata.ts Changed NFT metadata fetching to batched requests with throttling and immediate error checking.
packages/thirdweb/src/extensions/erc721/drops/write/updateMetadata.test.ts Added test case for handling very large batch metadata updates with extended timeout.
.changeset/breezy-dodos-hunt.md, .changeset/five-sheep-crash.md, .changeset/green-olives-unite.md Added changeset files documenting patch updates for optional client ID and large NFT collection metadata handling.

Sequence Diagram(s)

sequenceDiagram
    participant TestSuite as "7702 Minimal Account Test"
    participant Wallet as "In-App Wallet"
    participant Sepolia as "Sepolia Chain"
    participant Account as "Minimal Account"

    TestSuite->>Wallet: Configure with EIP-7702, gas sponsorship
    TestSuite->>Wallet: Connect as guest to Sepolia
    Wallet->>Sepolia: Connect and authenticate
    TestSuite->>Account: Prepare two zero-value transactions
    TestSuite->>Wallet: Send batch transactions via Account
    Wallet->>Sepolia: Submit batch transaction
    Sepolia-->>Wallet: Return transaction hash
    Wallet-->>TestSuite: Return transaction hash
    TestSuite->>TestSuite: Assert transaction hash is defined
Loading
sequenceDiagram
    participant GuestAuth as "guestAuthenticate"
    participant Server as "Authentication Server"

    GuestAuth->>Server: POST authentication request
    Server-->>GuestAuth: Respond with status and body
    alt Response not OK
        GuestAuth->>GuestAuth: Read response body text
        GuestAuth->>GuestAuth: Throw error with status, statusText, and body
    else Response OK
        GuestAuth->>GuestAuth: Proceed as normal
    end
Loading

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

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

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 54651ba and 0831769.

📒 Files selected for processing (10)
  • .changeset/breezy-dodos-hunt.md (1 hunks)
  • .changeset/five-sheep-crash.md (1 hunks)
  • .changeset/green-olives-unite.md (1 hunks)
  • packages/engine/src/configure.ts (1 hunks)
  • packages/insight/src/configure.ts (1 hunks)
  • packages/thirdweb/src/extensions/erc721/drops/write/updateMetadata.test.ts (1 hunks)
  • packages/thirdweb/src/extensions/erc721/drops/write/updateMetadata.ts (1 hunks)
  • packages/thirdweb/src/wallets/in-app/core/actions/get-enclave-user-status.ts (0 hunks)
  • packages/thirdweb/src/wallets/in-app/core/authentication/guest.ts (1 hunks)
  • packages/thirdweb/src/wallets/in-app/core/eip7702/minimal-account.test.ts (1 hunks)
💤 Files with no reviewable changes (1)
  • packages/thirdweb/src/wallets/in-app/core/actions/get-enclave-user-status.ts
✅ Files skipped from review due to trivial changes (3)
  • .changeset/breezy-dodos-hunt.md
  • .changeset/five-sheep-crash.md
  • .changeset/green-olives-unite.md
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/thirdweb/src/wallets/in-app/core/authentication/guest.ts
  • packages/thirdweb/src/wallets/in-app/core/eip7702/minimal-account.test.ts
  • packages/insight/src/configure.ts
🧰 Additional context used
🧬 Code Graph Analysis (1)
packages/thirdweb/src/extensions/erc721/drops/write/updateMetadata.test.ts (2)
packages/thirdweb/src/exports/thirdweb.ts (2)
  • getContract (69-69)
  • sendAndConfirmTransaction (140-140)
packages/thirdweb/src/extensions/erc721/drops/write/updateMetadata.ts (1)
  • updateMetadata (130-138)
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: E2E Tests (pnpm, esbuild)
  • GitHub Check: E2E Tests (pnpm, webpack)
  • GitHub Check: E2E Tests (pnpm, vite)
  • GitHub Check: Size
  • GitHub Check: Build Packages
  • GitHub Check: Unit Tests
  • GitHub Check: Lint Packages
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (3)
packages/engine/src/configure.ts (1)

5-5: LGTM! Clean implementation of optional clientId.

The change properly makes clientId optional, and the existing conditional logic in the configure function (line 14) already handles this case correctly by only adding the header when clientId is present.

packages/thirdweb/src/extensions/erc721/drops/write/updateMetadata.ts (1)

51-75: Excellent performance optimization for large NFT collections!

The batched processing approach effectively addresses performance and reliability issues when handling large NFT collections:

  • Batch size of 50: Reasonable chunk size that balances performance and memory usage
  • 500ms delays: Smart throttling to prevent rate limiting and system overload
  • Intermediate validation: Early error detection improves debugging experience
  • Explicit useIndexer: false: Ensures consistent behavior across different environments
  • Proper delay logic: Correctly skips delay after the final batch

This implementation significantly improves the developer experience when working with large datasets.

packages/thirdweb/src/extensions/erc721/drops/write/updateMetadata.test.ts (1)

84-125: Great test coverage for large batch processing!

This test effectively validates the new batched metadata update functionality:

  • Large dataset: 1000 NFTs properly exercises the batching logic implemented in the main function
  • Extended timeout: 10-minute timeout appropriately accommodates the processing time with delays
  • Focused validation: Testing the first page (100 NFTs) is sufficient to verify that batching doesn't break the update functionality
  • Proper structure: Follows the established test pattern with clear setup, execution, and assertions

This test ensures the performance optimizations don't compromise correctness when handling large NFT collections.

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added packages SDK Involves changes to the thirdweb SDK labels May 26, 2025
Copy link
Member Author


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.

Copy link
Contributor

github-actions bot commented May 26, 2025

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 61.75 KB (0%) 1.3 s (0%) 261 ms (+44.22% 🔺) 1.5 s
thirdweb (cjs) 344.4 KB (0%) 6.9 s (0%) 1.2 s (-4.02% 🔽) 8.1 s
thirdweb (minimal + tree-shaking) 5.69 KB (0%) 114 ms (0%) 69 ms (+737.99% 🔺) 183 ms
thirdweb/chains (tree-shaking) 531 B (0%) 11 ms (0%) 32 ms (+692.72% 🔺) 43 ms
thirdweb/react (minimal + tree-shaking) 19.54 KB (0%) 391 ms (0%) 77 ms (+269.82% 🔺) 468 ms

Copy link

codecov bot commented May 26, 2025

Codecov Report

Attention: Patch coverage is 60.71429% with 11 lines in your changes missing coverage. Please review.

Project coverage is 55.70%. Comparing base (5139857) to head (0831769).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
...eb/src/wallets/in-app/core/authentication/guest.ts 0.00% 6 Missing ⚠️
...rc/extensions/erc721/drops/write/updateMetadata.ts 77.27% 4 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7158      +/-   ##
==========================================
+ Coverage   55.68%   55.70%   +0.02%     
==========================================
  Files         904      904              
  Lines       58340    58358      +18     
  Branches     4107     4114       +7     
==========================================
+ Hits        32484    32510      +26     
+ Misses      25751    25743       -8     
  Partials      105      105              
Flag Coverage Δ
packages 55.70% <60.71%> (+0.02%) ⬆️
Files with missing lines Coverage Δ
...ets/in-app/core/actions/get-enclave-user-status.ts 77.77% <ø> (-0.80%) ⬇️
...rc/extensions/erc721/drops/write/updateMetadata.ts 82.97% <77.27%> (+1.72%) ⬆️
...eb/src/wallets/in-app/core/authentication/guest.ts 85.00% <0.00%> (-12.15%) ⬇️

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

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 (2)
packages/thirdweb/src/wallets/in-app/core/authentication/guest.ts (1)

48-53: Excellent error handling improvement, but add test coverage.

The enhanced error reporting with HTTP status, status text, and response body significantly improves debugging capabilities for guest authentication failures.

Consider adding test coverage for this error path as indicated by the static analysis. Error handling scenarios are critical to test for robustness.

// Add test case like:
it("should provide detailed error message on authentication failure", async () => {
  // Mock failed response and verify error message format
});
🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 49-53: packages/thirdweb/src/wallets/in-app/core/authentication/guest.ts#L49-L53
Added lines #L49 - L53 were not covered by tests

packages/thirdweb/src/wallets/in-app/core/eip7702/minimal-account.test.ts (1)

12-43: Good foundation for EIP-7702 testing, consider expanding assertions.

The test correctly validates basic batch transaction functionality with EIP-7702 execution mode. The conditional execution using TW_SECRET_KEY is appropriate for integration tests.

Consider enhancing the test with more comprehensive assertions:

    const result = await sendBatchTransaction({
      account,
      transactions: [tx1, tx2],
    });
    expect(result.transactionHash).toBeDefined();
+   expect(result.transactionHash).toMatch(/^0x[a-fA-F0-9]{64}$/);
+   
+   // Optionally verify transaction was actually mined
+   // const receipt = await waitForReceipt(result);
+   // expect(receipt.status).toBe("success");

This would provide better validation of the transaction hash format and could include verification that the transaction was successfully processed.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9479d25 and 54651ba.

📒 Files selected for processing (4)
  • packages/insight/src/configure.ts (1 hunks)
  • packages/thirdweb/src/wallets/in-app/core/actions/get-enclave-user-status.ts (0 hunks)
  • packages/thirdweb/src/wallets/in-app/core/authentication/guest.ts (1 hunks)
  • packages/thirdweb/src/wallets/in-app/core/eip7702/minimal-account.test.ts (1 hunks)
💤 Files with no reviewable changes (1)
  • packages/thirdweb/src/wallets/in-app/core/actions/get-enclave-user-status.ts
🧰 Additional context used
🧬 Code Graph Analysis (1)
packages/thirdweb/src/wallets/in-app/core/eip7702/minimal-account.test.ts (3)
packages/engine/src/client/client.gen.ts (1)
  • client (24-28)
packages/thirdweb/src/exports/thirdweb.ts (1)
  • prepareTransaction (102-102)
packages/thirdweb/src/exports/wallets.ts (1)
  • generateAccount (31-31)
🪛 GitHub Check: codecov/patch
packages/thirdweb/src/wallets/in-app/core/authentication/guest.ts

[warning] 49-53: packages/thirdweb/src/wallets/in-app/core/authentication/guest.ts#L49-L53
Added lines #L49 - L53 were not covered by tests

🔇 Additional comments (1)
packages/insight/src/configure.ts (1)

5-5: LGTM! Good API improvement.

Making clientId optional enhances API flexibility while maintaining backward compatibility. The existing conditional logic in the configure function already handles optional clientId correctly.

@joaquim-verges joaquim-verges force-pushed the _Insight_Make_clientId_optional_and_improve_error_handling branch from 54651ba to 222d3e2 Compare May 26, 2025 21:27
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.

1 participant