Skip to content

[SDK] Improve quote error handling #7147

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

Merged
merged 1 commit into from
May 23, 2025

Conversation

joaquim-verges
Copy link
Member

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


PR-Codex overview

This PR focuses on improving error handling in the thirdweb package by introducing a new error type and updating the error message function to accommodate it.

Detailed summary

  • Added "INTERNAL_SERVER_ERROR" to the error types in Errors.ts.
  • Updated getErrorMessage in errors.ts to handle "INTERNAL_SERVER_ERROR" with a specific message.
  • Removed outdated error handling for "MINIMUM_PURCHASE_AMOUNT".

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

Summary by CodeRabbit

  • Bug Fixes

    • Improved error messages for quote-related issues, providing clearer feedback when an unknown server error occurs.
    • Removed outdated error messaging for minimum purchase amount errors.
  • Chores

    • Updated internal documentation to reflect these changes.

Copy link

vercel bot commented May 23, 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 23, 2025 8:31pm
login ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 23, 2025 8:31pm
thirdweb_playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 23, 2025 8:31pm
thirdweb-www ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 23, 2025 8:31pm
wallet-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 23, 2025 8:31pm

Copy link

changeset-bot bot commented May 23, 2025

🦋 Changeset detected

Latest commit: d37f7cc

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

This PR includes changesets to release 2 packages
Name Type
thirdweb Patch
@thirdweb-dev/wagmi-adapter 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
Contributor

coderabbitai bot commented May 23, 2025

Walkthrough

A new changeset file was added to document a patch update for the "thirdweb" package, specifically addressing better error handling for quote-related errors. The ErrorCode type was extended to include "INTERNAL_SERVER_ERROR", and the getErrorMessage function was updated to handle this new error code with a specific UI error response, while removing handling for "MINIMUM_PURCHASE_AMOUNT".

Changes

File(s) Change Summary
.changeset/tall-walls-juggle.md Added a changeset file documenting a patch update for improved quote error handling.
packages/thirdweb/src/bridge/types/Errors.ts Extended ErrorCode type to include "INTERNAL_SERVER_ERROR".
packages/thirdweb/src/react/web/utils/errors.ts Updated getErrorMessage to handle "INTERNAL_SERVER_ERROR" with a specific UI error; removed handling for "MINIMUM_PURCHASE_AMOUNT" and related logging.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant UI
    participant getErrorMessage
    participant ApiError

    User->>UI: Triggers action that may cause an error
    UI->>getErrorMessage: Passes error object
    getErrorMessage->>ApiError: Checks if error is ApiError and code
    alt code == "INTERNAL_SERVER_ERROR"
        getErrorMessage-->>UI: Returns UiError with code "INTERNAL_SERVER_ERROR"
    else other error
        getErrorMessage-->>UI: Returns UiError with code "UNABLE_TO_GET_PRICE_QUOTE"
    end
    UI-->>User: Displays error message
Loading

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.

📜 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 adc738e and d37f7cc.

📒 Files selected for processing (3)
  • .changeset/tall-walls-juggle.md (1 hunks)
  • packages/thirdweb/src/bridge/types/Errors.ts (1 hunks)
  • packages/thirdweb/src/react/web/utils/errors.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: E2E Tests (pnpm, esbuild)
  • GitHub Check: Unit Tests
  • GitHub Check: E2E Tests (pnpm, webpack)
  • GitHub Check: Size
  • GitHub Check: Lint Packages
  • GitHub Check: E2E Tests (pnpm, vite)
  • GitHub Check: Build Packages
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (4)
packages/thirdweb/src/bridge/types/Errors.ts (1)

6-6: LGTM! Clean addition to the error code union.

The new "INTERNAL_SERVER_ERROR" error code follows the existing naming convention and is properly integrated into the ErrorCode union type, maintaining type safety throughout the codebase.

packages/thirdweb/src/react/web/utils/errors.ts (2)

12-18: Well-implemented error handling for internal server errors.

The new conditional block properly handles "INTERNAL_SERVER_ERROR" cases with:

  • Appropriate error code propagation
  • Consistent user-friendly messaging
  • Generic message that avoids exposing internal system details

12-18:

✅ Verification successful

Verify removal of MINIMUM_PURCHASE_AMOUNT handling.

Since the AI summary mentions that "MINIMUM_PURCHASE_AMOUNT" error handling was removed, please ensure this doesn't break any existing functionality or leave orphaned references.


🏁 Script executed:

#!/bin/bash
# Description: Check for any remaining references to MINIMUM_PURCHASE_AMOUNT error handling
# Expected: Should find minimal or no references, confirming safe removal

echo "Searching for MINIMUM_PURCHASE_AMOUNT references..."
rg -i "MINIMUM_PURCHASE_AMOUNT" --type ts --type tsx --type js --type jsx

echo -e "\nSearching for related minimum purchase error patterns..."
rg -i "minimum.*purchase.*amount" --type ts --type tsx --type js --type jsx

echo -e "\nChecking for any error handling tests that might need updates..."
fd -e test.ts -e test.tsx -e spec.ts -e spec.tsx | head -10 | xargs rg -l "error|Error" 2>/dev/null || echo "No test files found with error handling"

Length of output: 859


#!/bin/bash
# Refined search for any lingering references to MINIMUM_PURCHASE_AMOUNT or related patterns

echo "Searching for MINIMUM_PURCHASE_AMOUNT references in .ts, .tsx, .js, .jsx..."
rg -i "MINIMUM_PURCHASE_AMOUNT" -g "*.ts" -g "*.tsx" -g "*.js" -g "*.jsx" \
  && echo "Found references above." || echo "No MINIMUM_PURCHASE_AMOUNT references found."

echo -e "\nSearching for 'minimum.*purchase.*amount' patterns in source files..."
rg -i "minimum.*purchase.*amount" -g "*.ts" -g "*.tsx" -g "*.js" -g "*.jsx" \
  && echo "Found related patterns above." || echo "No related patterns found."

echo -e "\nSearching for test files referencing minimum purchase errors..."
rg -i "minimum.*purchase.*amount" -g "*test.*" -g "*spec.*" \
  && echo "Found test references above." || echo "No test references found."

✅ Removal of MINIMUM_PURCHASE_AMOUNT validated
No occurrences of MINIMUM_PURCHASE_AMOUNT (or related “minimum purchase amount” patterns) remain in .ts, .tsx, .js, or .jsx files, and no test suites reference it. Safe to remove.

.changeset/tall-walls-juggle.md (1)

1-5: Proper changeset documentation.

The changeset correctly documents this as a patch-level change to the "thirdweb" package with an appropriate description that aligns with the error handling improvements.

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

@joaquim-verges joaquim-verges changed the title [thirdweb] Improve quote error handling [SDK] Improve quote error handling May 23, 2025
@github-actions github-actions bot added packages SDK Involves changes to the thirdweb SDK labels May 23, 2025
@joaquim-verges joaquim-verges marked this pull request as ready for review May 23, 2025 20:22
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

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 56.71 KB (0%) 1.2 s (0%) 244 ms (+90.17% 🔺) 1.4 s
thirdweb (cjs) 309.55 KB (0%) 6.2 s (0%) 1.1 s (+4.3% 🔺) 7.3 s
thirdweb (minimal + tree-shaking) 5.69 KB (0%) 114 ms (0%) 60 ms (+669.14% 🔺) 174 ms
thirdweb/chains (tree-shaking) 531 B (0%) 11 ms (0%) 29 ms (+884.26% 🔺) 39 ms
thirdweb/react (minimal + tree-shaking) 19.5 KB (0%) 390 ms (0%) 33 ms (+65.9% 🔺) 423 ms

Copy link

codecov bot commented May 23, 2025

Codecov Report

Attention: Patch coverage is 0% with 7 lines in your changes missing coverage. Please review.

Project coverage is 55.59%. Comparing base (adc738e) to head (d37f7cc).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
packages/thirdweb/src/react/web/utils/errors.ts 0.00% 7 Missing ⚠️

❌ Your patch status has failed because the patch coverage (0.00%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7147      +/-   ##
==========================================
- Coverage   55.61%   55.59%   -0.02%     
==========================================
  Files         903      903              
  Lines       58236    58232       -4     
  Branches     4100     4097       -3     
==========================================
- Hits        32387    32375      -12     
- Misses      25744    25754      +10     
+ Partials      105      103       -2     
Flag Coverage Δ
packages 55.59% <0.00%> (-0.02%) ⬇️
Files with missing lines Coverage Δ
packages/thirdweb/src/bridge/types/Errors.ts 100.00% <ø> (ø)
packages/thirdweb/src/react/web/utils/errors.ts 5.88% <0.00%> (+0.61%) ⬆️

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

@joaquim-verges joaquim-verges merged commit 3489ece into main May 23, 2025
26 of 27 checks passed
@joaquim-verges joaquim-verges deleted the _thirdweb_Improve_quote_error_handling branch May 23, 2025 22:43
@joaquim-verges joaquim-verges mentioned this pull request May 23, 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.

1 participant