Skip to content
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

Fixed origins api for pypi components throwing 500 error when invalid package is provided #1172

Merged

Conversation

yashkohli88
Copy link
Contributor

@yashkohli88 yashkohli88 commented Aug 12, 2024

Below are the tasks completed as a part of this fix -

  • Code updated to introduce try-catch block which checks if the error status code is 404, it returns an empty response. It throws error in other scenarios.
  • A separate function has been created to refactor the existing code which contained repeated set of statements, and to perform unit testing on the changes.
  • encodeURIComponent has also been introduced where we are creating URL to prevent injection.
  • New Test cases added for happy path and two error scenarios with status code 404 and 400 to check the response.
  • Fixture added for the response of the positive testcase.

List of testcases added in the origins.js file related to the changes -

  • Return proper response when valid package is provided as input
  • Return blank response when invalid package is provided as input
  • Throws error response when error other than invalid package (status 404) is returned from package manager response.

This fix is related to Issue 1182

@yashkohli88 yashkohli88 reopened this Aug 12, 2024
@yashkohli88 yashkohli88 marked this pull request as draft August 12, 2024 15:46
@yashkohli88 yashkohli88 changed the title Fix origins pypi error handling Fixed origins api for pypi components throwing 500 error when invalid group id is provided Aug 21, 2024
@yashkohli88 yashkohli88 changed the title Fixed origins api for pypi components throwing 500 error when invalid group id is provided Fixed origins api for pypi components throwing 500 error when invalid package is provided Aug 21, 2024
Copy link
Collaborator

@elrayle elrayle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice to see 500 errors being addressed. Thanks!

@elrayle
Copy link
Collaborator

elrayle commented Aug 28, 2024

@yashkohli88 The PR is marked as a work in progress. Is this ready for review? NOTE: There are some conflicts to resolve.

@elrayle elrayle marked this pull request as ready for review August 28, 2024 15:01
@elrayle elrayle merged commit c008d00 into clearlydefined:master Aug 28, 2024
4 checks passed
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.

3 participants