Skip to content

OSIS-166: preserve Vault server faults (5xx) instead of masking them as 400#169

Open
anurag4DSB wants to merge 1 commit into
mainfrom
bugfix/OSIS-166-preserve-vault-5xx-status-mainport
Open

OSIS-166: preserve Vault server faults (5xx) instead of masking them as 400#169
anurag4DSB wants to merge 1 commit into
mainfrom
bugfix/OSIS-166-preserve-vault-5xx-status-mainport

Conversation

@anurag4DSB

Copy link
Copy Markdown
Contributor

Intent: why does this change exist?

Several create and update methods caught any failure and rethrew it as 400 BAD_REQUEST, which masked a genuine Vault server fault (5xx) as a client error and hid real outages behind a misleading status.

System impact: what's affected, including downstream?

The error status surfaced by createTenant, createUser, createS3Credential, updateTenant, updateCredentialStatus, and updateUser. VaultServiceException extends Spring's ResponseStatusException, so the carried status is what the caller sees.

Preserved behavior: what explicitly stays the same?

Client-side rejections still map to 400 with the original kept as the cause (updateTenant keeps its errorCode and reason), and all existing error logging is unchanged. Only genuine 5xx faults change.

Intended change: what's different after this PR?

A VaultServiceException carrying a 5xx status is rethrown unchanged so the real server status reaches the caller, instead of being downgraded to 400. A small toResponseException helper centralizes the rule; updateTenant gets an inline 5xx passthrough to keep its errorCode and reason contract. Tests pin that a 500 from Vault stays 500 on create and update.

Verification: how do we know this worked, or how would we know if it didn't?

Ran the full osis-core test module including the JaCoCo gate: green. The new tests fail if a Vault 5xx is downgraded to 400.

@claude

claude Bot commented Jun 26, 2026

Copy link
Copy Markdown

LGTM — the 5xx passthrough logic is correct. The toResponseException helper properly checks for VaultServiceException with a 5xx status before falling back to 400, and the inline variant in updateTenant correctly preserves errorCode/reason for 4xx while still surfacing genuine server faults. Tests pin both create and update paths.

Review by Claude Code

@anurag4DSB anurag4DSB marked this pull request as ready for review June 26, 2026 10:26
@anurag4DSB anurag4DSB requested a review from a team as a code owner June 26, 2026 10:26
});

assertEquals(500, exception.getStatus().value(),
"a genuine Vault server fault must not be downgraded to 400");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nitpick: I prefer when the tests simply state what they check, rather than focus on the regression that it's fixing, as the user may not have the context to understand the reason of "must not be downgraded to 400" (unless the test is tailored to a particular regression which is not the case here as the test has value more generally, outside of the bug it's fixing), I'd rather say something like "a genuine Vault server fault must be thrown as its original 500 error code".

Just a little suggestion, but up to you!

Comment on lines +1063 to +1064
// A client-side Vault rejection maps to 400; a genuine Vault server fault (5xx) is
// surfaced unchanged instead of being masked as a client 400.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

For the same reason I commented in https://github.com/scality/osis/pull/169/changes#r3482873683, I think it's best not to talk about past regressions in fixed code to avoid confusing the reader. May not warrant a comment at all actually, I think the code is self-explanatory. Or simply state the list of possible error codes and their mapping if it helps understanding.

Same comment for the other occurrences of a similar comment.

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