Skip to content

Fix REST responses for failed Admin operations #2291

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

Merged
merged 2 commits into from
Aug 15, 2025

Conversation

XN137
Copy link
Contributor

@XN137 XN137 commented Aug 7, 2025

the boolean return values of many methods in PolarisAdminService
were often simply not getting used at all, thus the REST api returned
success in those cases even though the PrivilegeResult was marked
as failed.
due to this fix a silently failing test now needs to be adjusted.

we return the PrivilegeResult instead of a boolean to give the
client at least some indication of what has gone wrong on the server
side.

note that some of the other operations were throwing Expcetions already,
which are already reported back correctly to the client.

@@ -640,7 +661,7 @@ public Response addGrantToCatalogRole(
.log("Don't know how to handle privilege grant: {}", grantRequest);
return Response.status(Response.Status.BAD_REQUEST).build();
}
return Response.status(Response.Status.CREATED).build();
return toResponse(result, Response.Status.CREATED);
Copy link
Member

Choose a reason for hiding this comment

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

This means that errors were not propagated to clients, right?

Copy link
Contributor Author

@XN137 XN137 Aug 7, 2025

Choose a reason for hiding this comment

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

yeah, some methods do throw exceptions internally (and those get propagated to clients correctly) but the returned boolean value of the methods was often ignored.
as part of this PR we have to fix a test in PolarisManagementServiceIntegrationTest.java which was silently failing before.

@XN137 XN137 force-pushed the fix-admin-rest-responses branch 3 times, most recently from 9cf05b2 to d9a55c1 Compare August 12, 2025 07:15
the `boolean` return values of many methods in `PolarisAdminService`
were often simply not getting used at all, thus the REST api returned
success in those cases even though the `PrivilegeResult` was marked
as failed.
due to this fix a silently failing test now needs to be adjusted.

we return the `PrivilegeResult` instead of a `boolean` to give the
client at least some indication of what has gone wrong on the server
side.

note that some of the other operations were throwing Expcetions already,
which are already reported back correctly to the client.
@XN137 XN137 force-pushed the fix-admin-rest-responses branch from d9a55c1 to 56ad6dc Compare August 12, 2025 08:34
.returns(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), Response::getStatus);
assertThat(response.hasEntity()).isTrue();
ErrorResponse errorResponse = response.readEntity(ErrorResponse.class);
assertThat(errorResponse.message()).contains("Operation failed: GRANT_NOT_FOUND");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

there could be an argument that GRANT_NOT_FOUND should be a 404 instead of internal server error but it would mean we need to translate all BaseResult.ReturnStatus values to a proper HTTP code.
i think this can be figured out in a followup and we should first stop silently failing in those cases.

Copy link
Member

Choose a reason for hiding this comment

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

Hm - HTTP/500 feels odd, as it's rather a user (argument) error. HTTP/400 would be better IMHO.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok switched to HTTP/400

@XN137 XN137 marked this pull request as ready for review August 12, 2025 08:36
@github-project-automation github-project-automation bot moved this from PRs In Progress to Ready to merge in Basic Kanban Board Aug 12, 2025
@snazy
Copy link
Member

snazy commented Aug 14, 2025

If nobody objects, I'll merge later today.

@snazy snazy merged commit 6e036e0 into apache:main Aug 15, 2025
12 checks passed
@github-project-automation github-project-automation bot moved this from Ready to merge to Done in Basic Kanban Board Aug 15, 2025
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