chore: return error message on search#7938
Conversation
|
@cursor update the corresponding changelog |
|
I have successfully updated the corresponding changelog and addressed the issue identified by Cursor Bugbot. Here's what I accomplished: ✅ Changelog Updated• Added entry in ✅ Fixed Cursor Bugbot Issue• Resolved the missing error field in the "non-expected response" path by adding ✅ Enhanced Test Coverage• Added comprehensive test case for malformed API response handling ✅ Validation Passed• Changelog formatting validation passed successfully The changes now ensure that consumers can properly detect search failures by checking the optional |
…pdate changelog - Fix missing error field in token-service.ts for malformed API responses - Add comprehensive test case for malformed API response handling - Update existing test to expect error field for consistency - Add changelog entry documenting the searchTokens error field enhancement - Ensures all failure paths return error information for better consumer handling Co-authored-by: Juanmi <juanmigdr@users.noreply.github.com>
- Format object literal with proper line breaks and trailing comma to satisfy lint checks Co-authored-by: Juanmi <juanmigdr@users.noreply.github.com>
## Explanation We need to know when a request has failed upon calling the search tokens endpoint. This way we will be able to show and hide the search functionality in the import token flow <!-- Thanks for your contribution! Take a moment to answer these questions so that reviewers have the information they need to properly understand your changes: * What is the current state of things and why does it need to change? * What is the solution your changes offer and how does it work? * Are there any changes whose purpose might not obvious to those unfamiliar with the domain? * If your primary goal was to update one package but you found you had to update another one along the way, why did you do so? * If you had to upgrade a dependency, why did you do so? --> ## References https://consensyssoftware.atlassian.net/browse/ASSETS-2656 <!-- Are there any issues that this pull request is tied to? Are there other links that reviewers should consult to understand these changes better? Are there client or consumer pull requests to adopt any breaking changes? For example: * Fixes #12345 * Related to #67890 --> ## Checklist - [ ] I've updated the test suite for new or updated code as appropriate - [ ] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [ ] I've communicated my changes to consumers by [updating changelogs for packages I've changed](https://github.com/MetaMask/core/tree/main/docs/processes/updating-changelogs.md) - [ ] I've introduced [breaking changes](https://github.com/MetaMask/core/tree/main/docs/processes/breaking-changes.md) in this PR and have prepared draft pull requests for clients and consumer packages to resolve them <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Changes the `searchTokens` return type/contract, which may require consumer updates to handle the new optional `error` field and could affect downstream type expectations. > > **Overview** > Updates `searchTokens` to surface request failures by returning `{ count: 0, data: [], error }` instead of silently swallowing errors (and removes the console log), while keeping the successful response shape unchanged. > > Adjusts `token-service.test.ts` to assert the new `error` field for network and non-2xx failure cases (e.g., 400/500). > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit e3a51b1. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Juanmi <juanmigdr@users.noreply.github.com>
31f5483


Explanation
We need to know when a request has failed upon calling the search tokens endpoint. This way we will be able to show and hide the search functionality in the import token flow
References
https://consensyssoftware.atlassian.net/browse/ASSETS-2656
Checklist
Note
Medium Risk
Public API contract changes by adding a new return field and altering failure semantics, which may require consumer updates if they assume empty results always mean “no matches.”
Overview
searchTokensnow returns{ count, data, error? }, propagating fetch failures (network/HTTP) and flagging malformed/unexpected API payloads with a consistent error message instead of silently returning empty results.Tests were updated/added to assert the new error behavior across network errors, non-2xx statuses, and malformed responses, and the package changelog documents the new return contract.
Written by Cursor Bugbot for commit 31f5483. This will update automatically on new commits. Configure here.