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

Add specific error code to REST API #2443

Merged
merged 7 commits into from
Oct 22, 2021

Conversation

dimas-b
Copy link
Member

@dimas-b dimas-b commented Oct 20, 2021

  • Add errorCode to the NessieError object, whose JSON representation
    is set to clients as HTTP error response payload. This is necessary to
    allow clients to distinguish Nessie-specific failure mode that fall
    under the same HTTP status code.

  • Note: this will break Nessie error response handling in older java clients.

  • Add more specific exception classes to nessie-model

  • Update java client to unwrap and throw (more) specific exceptions based
    on NessieError payload error codes.

  • Corresponding Python client changes to follow in a separate commit.

  • Fix a TreeApiImpl.meta() to throw a NessieIllegalArgumentException
    instead of NessieConflictException when the committer is set by the user.

  • Refactor toHash() in TreeApiImpl to remove unnecessary Optional

  • Minor code cleanup in AbstractTestRest

Closes #477


Non-trivial changes are in ErrorCode, NessieError, ResponseCheckFilter, TreeApiImpl (and other ApiImpl classes). The rest of changes is just the ripple effect of the former.

@dimas-b dimas-b added java Pull requests that update Java code pr-native run native test pr-jackson labels Oct 20, 2021
@codecov
Copy link

codecov bot commented Oct 20, 2021

Codecov Report

Merging #2443 (e6f1dce) into main (834b16b) will increase coverage by 0.23%.
The diff coverage is 82.78%.

Impacted file tree graph

@@             Coverage Diff              @@
##               main    #2443      +/-   ##
============================================
+ Coverage     83.96%   84.19%   +0.23%     
- Complexity     1903     1916      +13     
============================================
  Files           246      251       +5     
  Lines         10714    10769      +55     
  Branches        769      764       -5     
============================================
+ Hits           8996     9067      +71     
+ Misses         1405     1397       -8     
+ Partials        313      305       -8     
Flag Coverage Δ
java 84.18% <82.78%> (+0.22%) ⬆️
javascript 74.41% <ø> (ø)
python 85.92% <ø> (+0.29%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...tnessie/error/BaseNessieClientServerException.java 94.73% <0.00%> (-5.27%) ⬇️
...g/projectnessie/error/NessieConflictException.java 66.66% <ø> (ø)
...g/projectnessie/error/NessieNotFoundException.java 100.00% <ø> (ø)
...g/projectnessie/services/impl/ContentsApiImpl.java 72.72% <0.00%> (+3.16%) ⬆️
...a/org/projectnessie/services/impl/TreeApiImpl.java 75.92% <34.78%> (+1.95%) ⬆️
...tnessie/error/NessieContentsNotFoundException.java 60.00% <60.00%> (ø)
...e/error/NessieReferenceAlreadyExistsException.java 71.42% <71.42%> (ø)
...nessie/error/NessieReferenceConflictException.java 71.42% <71.42%> (ø)
...java/org/projectnessie/jaxrs/AbstractTestRest.java 95.10% <97.67%> (+0.11%) ⬆️
...projectnessie/client/rest/ResponseCheckFilter.java 90.90% <100.00%> (+4.70%) ⬆️
... and 14 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 834b16b...e6f1dce. Read the comment docs.

Copy link
Member

@snazy snazy left a comment

Choose a reason for hiding this comment

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

I like the separation for the not-found case.
Not sure about the added nessie-iae though.

@snazy snazy added this to the 0.11.1 milestone Oct 21, 2021
@dimas-b
Copy link
Member Author

dimas-b commented Oct 21, 2021

@snazy : do we want this in 0.11.1? It breaks REST API, technically... I guess 0.12 might be preferable 🤔

* Add `errorCode` to the `NessieError` object, whose JSON representation
  is set to clients as HTTP error response payload. This is necessary to
  allow clients to distinguish Nessie-specific failure mode that fall
  under the same HTTP status code.

* Note: this will break Nessie error response handling in older java clients.

* Add more specific exception classes to `nessie-model`

* Update java client to unwrap and throw (more) specific exceptions based
  on `NessieError` payload error codes.

* Corresponding Python client changes to follow in a separate commit.

* Fix a `TreeApiImpl.meta()` to throw a NessieIllegalArgumentException
  instead of NessieConflictException when the committer is set by the user.

* Refactor `toHash()` in `TreeApiImpl` to remove unnecessary `Optional`

* Minor code cleanup in `AbstractTestRest`

Closes projectnessie#477
@dimas-b dimas-b force-pushed the api-exception-classes branch from 8585680 to 521e53e Compare October 21, 2021 16:51
@dimas-b dimas-b marked this pull request as draft October 21, 2021 16:52
@dimas-b dimas-b marked this pull request as ready for review October 22, 2021 13:51
@dimas-b dimas-b merged commit f7ab9aa into projectnessie:main Oct 22, 2021
@dimas-b dimas-b deleted the api-exception-classes branch October 22, 2021 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
java Pull requests that update Java code pr-native run native test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Specialize and document Nessie Exception classes
3 participants