Skip to content

Fix library upload error messages and stale SVG key crash#32

Open
ImranFarhat01 wants to merge 1 commit into
FOSSEE:developfrom
ImranFarhat01:fix/library-upload-error-clean
Open

Fix library upload error messages and stale SVG key crash#32
ImranFarhat01 wants to merge 1 commit into
FOSSEE:developfrom
ImranFarhat01:fix/library-upload-error-clean

Conversation

@ImranFarhat01

Copy link
Copy Markdown

Problem

  • Any upload failure showed a generic 'An Error Occured' message with no actionable information
  • The uploadSuccess reducer discarded the HTTP status code, storing only true/false
  • Re-uploading a library crashed with KeyError because save_libs globbed all SVGs in the output folder (including leftovers from previous uploads), then failed to find them in the current upload's component_details dict

Fix

  • Reducer stores HTTP status code in uploadError field on failure
  • Component reads uploadError via useSelector
  • Specific messages shown for 400, 401, 403, 413, 500 status codes
  • Added uploadError to useEffect dependency array to satisfy eslint
  • Skip SVGs not present in component_details instead of raising KeyError

Testing

  • Uploaded valid .lib + .dcm files as a non-admin user → "Upload Successful" shown, component renders correctly on canvas
  • Uploaded invalid file → "Upload Failed: Invalid file format. Please upload valid .lib and .dcm files." shown
  • Re-upload of same library now succeeds instead of crashing

Problem:
- Any upload failure showed generic 'An Error Occured' message
- uploadSuccess reducer discarded HTTP status code, storing only true/false
- Re-uploading a library crashed with KeyError because save_libs globbed
  all SVGs in the output folder including leftovers from previous uploads,
  then failed to find them in the current upload's component_details dict

Fix:
- Reducer stores HTTP status code in uploadError field on failure
- Component reads uploadError via useSelector
- Specific messages shown for 400, 401, 403, 413, 500 status codes
- Add uploadError to useEffect dependency array to satisfy eslint
- Skip SVGs not present in component_details instead of raising KeyError
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant