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

CMR-9848: When submitting multiple associations, if one fails CMR returns a 400 but still makes the other associations #2198

Merged
merged 37 commits into from
Dec 31, 2024

Conversation

jmaeng72
Copy link
Contributor

@jmaeng72 jmaeng72 commented Dec 11, 2024

Overview

What is the problem?

When some associations in POST request, fail, but some succeed. The response returns a 400 for association endpoints, but we want it to reflect the true state that some associations failed.

What is the Solution?

If a request with multiple associations returns with some successes and some failures, we will return a 207 MULT-STATUS instead, with each association having its own status of 200 or 400 based on success or failure.

Associations affected:

  • Tool
  • Service
  • Concept/Generic
  • Tag
  • Variable

New Expected Response Status Behavior:

  • 200 OK -- if all associations succeeded
  • 207 MULTI-STATUS -- if some associations succeeded and some failed due to user error
  • 400 BAD REQUEST -- if all associations failed due to user error

What areas of the application does this impact?

Search App

Checklist

  • I have updated/added unit and int tests that prove my fix is effective or that my feature works
  • New and existing unit and int tests pass locally and remotely
  • clj-kondo has been run locally and all errors corrected
  • I have removed unnecessary/dead code and imports in files I have changed
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have cleaned up integration tests by doing one or more of the following:
    • migrated any are2 tests to are3 in files I have changed
    • de-duped, consolidated, removed dead int tests
    • transformed applicable int tests into unit tests
    • refactored to reduce number of system state resets by updating fixtures (use-fixtures :each (ingest/reset-fixture {})) to be :once instead of :each

siwei xu and others added 28 commits June 5, 2024 10:22
@jmaeng72 jmaeng72 self-assigned this Dec 11, 2024
@codecov-commenter
Copy link

codecov-commenter commented Dec 11, 2024

Codecov Report

Attention: Patch coverage is 84.37500% with 15 lines in your changes missing coverage. Please review.

Project coverage is 58.26%. Comparing base (fe3fde2) to head (02f3f66).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
search-app/src/cmr/search/api/tags.clj 61.11% 6 Missing and 1 partial ⚠️
...rch-app/src/cmr/search/api/generic_association.clj 81.25% 2 Missing and 1 partial ⚠️
...nt-test/src/cmr/system_int_test/utils/tag_util.clj 86.66% 0 Missing and 2 partials ⚠️
search-app/src/cmr/search/api/association.clj 93.75% 0 Missing and 1 partial ⚠️
...est/src/cmr/system_int_test/utils/service_util.clj 93.33% 0 Missing and 1 partial ⚠️
...t-test/src/cmr/system_int_test/utils/tool_util.clj 92.85% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2198      +/-   ##
==========================================
+ Coverage   58.23%   58.26%   +0.03%     
==========================================
  Files        1056     1056              
  Lines       71012    71082      +70     
  Branches     2026     2033       +7     
==========================================
+ Hits        41354    41417      +63     
+ Misses      27771    27766       -5     
- Partials     1887     1899      +12     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jmaeng72 jmaeng72 merged commit d86c1d7 into master Dec 31, 2024
6 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.

4 participants