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

Improve handling of invalid pids #31

Merged
merged 1 commit into from
Jul 11, 2023
Merged

Conversation

kasperg
Copy link
Contributor

@kasperg kasperg commented Jul 7, 2023

If we try to return a item id contained within a list stored in the database we currently fail with a 422 Unprocessable Entity. This is not very helpful as the client cannot do anything to address this.

To address this we change the process logic to mark a problem with the list id by throwing a more general invalid argument exception. This can then be caught and handled in different situations where this might occur:

  • For situations where the item id is provided by the client we keep responding with a 422 error.
  • For situations where the item id is loaded from the database we log the error and return any remaining items.

The situation causing this issue is likely caused by a few faulty items being migrated into the database in the initial stage of the project. For v2 we have introduced stricter requirements for data formats. These are being enforced for new data but cause problems with existing data.

If we try to return a item id contained within a list stored in the
database we currently fail with a 422 Unprocessable Entity. This is not
very helpful as the client cannot do anything to address this.

To address this we change the process logic to mark a problem with the
list id by throwing a more general invalid argument exception. This can
then be caught and handled in different situations where this might 
occur:

- For situations where the item id is provided by the client we keep
responding with a 422 error.
- For situations where the item id is loaded from the database we log
the error and return any remaining items. 

The situation causing this issue is likely caused by a few faulty items
being migrated into the database in the initial stage of the project.
For v2 we have introduced stricter requirements for data formats. These
are being enforced for new data but cause problems with existing data.
@kasperg kasperg requested a review from spaceo July 7, 2023 09:51
Copy link
Contributor

@spaceo spaceo left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@kasperg kasperg merged commit 91cb4a0 into develop Jul 11, 2023
9 checks passed
@kasperg kasperg deleted the fix/handle-invalid-list-data branch July 11, 2023 06:56
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.

2 participants