fix: fix/error message upload [Backport release/0.5.z]#1138
Merged
Conversation
Signed-off-by: Carlos Feria <2582866+carlosthe19916@users.noreply.github.com> (cherry picked from commit 319e799)
10 tasks
Contributor
Reviewer's GuideBackport that centralizes Axios upload error message extraction in a shared utility and aligns UI + e2e tests with the new behavior for advisory and SBOM uploads. Sequence diagram for centralized Axios upload error handlingsequenceDiagram
actor User
participant UploadFiles
participant getAxiosErrorMessage
User->>UploadFiles: upload file
UploadFiles-->>UploadFiles: HTTP request via Axios
UploadFiles-->>UploadFiles: [error response received]
UploadFiles->>getAxiosErrorMessage: getAxiosErrorMessage(axiosError)
getAxiosErrorMessage-->>UploadFiles: errorMessage
UploadFiles-->>User: show errorMessage
Flow diagram for getAxiosErrorMessage decision logicflowchart TD
A[AxiosError received] --> B{response data exists}
B -->|no| H[Return axiosError.message]
B -->|yes| C{data.error and data.message are strings}
C -->|yes| D[base = error: message]
D --> E{data.details is string}
E -->|yes| F[Return base + '\n' + details]
E -->|no| G[Return base]
C -->|no| I{data.message is string}
I -->|yes| J[Return data.message]
I -->|no| K{data.error is string}
K -->|yes| L[Return data.error]
K -->|no| M{data is string}
M -->|yes| N[Return data]
M -->|no| H[Return axiosError.message]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- In
getAxiosErrorMessage, consider tightening the signature toAxiosError<unknown>and introducing a small runtime type guard for thedatashape so you can drop theanyand the eslint disable while still keeping the logic safe and explicit. - In
toHaveItemUploadStatus, when anexpectedStatus.messageis provided you no longer assert on the progress reaching 100%; forstatus: "success"you may still want to keep the 100% progress assertion to ensure the upload completed in addition to checking the message.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `getAxiosErrorMessage`, consider tightening the signature to `AxiosError<unknown>` and introducing a small runtime type guard for the `data` shape so you can drop the `any` and the eslint disable while still keeping the logic safe and explicit.
- In `toHaveItemUploadStatus`, when an `expectedStatus.message` is provided you no longer assert on the progress reaching 100%; for `status: "success"` you may still want to keep the 100% progress assertion to ensure the upload completed in addition to checking the message.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## release/0.5.z #1138 +/- ##
=================================================
+ Coverage 51.10% 51.34% +0.24%
=================================================
Files 256 256
Lines 5522 5523 +1
Branches 1672 1672
=================================================
+ Hits 2822 2836 +14
+ Misses 2432 2421 -11
+ Partials 268 266 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Backport of #1111 to
release/0.5.z.Summary by Sourcery
Improve upload error handling to surface API-provided messages for advisory and SBOM uploads.
Bug Fixes:
Enhancements:
Tests: