fix: expose HTTP status code via KeeperHTTPError on JSON-error path (KSM-919) - #65
Merged
stas-schaller merged 1 commit intoApr 30, 2026
Conversation
…KSM-919)
HandleHttpError now returns *KeeperHTTPError on all non-200 paths, making
the HTTP status code reachable via errors.As in addition to the error string.
The JSON-error path previously omitted the status code from the caller-returned
error while the non-JSON path already included it; both paths now produce a
consistent "HTTPStatus=N Error: ..." string. The POST Error wrapper uses
fmt.Errorf with %w to preserve the error chain.
Callers can branch on status without grepping stderr:
var khe *core.KeeperHTTPError
if errors.As(err, &khe) { ... }
CHANGELOG.md updated with breaking-change callout and migration snippet.
Closes KSM-919
stas-schaller
merged commit Apr 30, 2026
168d2c0
into
release/sdk/golang/core/v1.7.0
2 checks passed
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
HandleHttpErrornow returns*KeeperHTTPErroron all non-200 paths (JSON-error, raw-body, and non-JSON), making the HTTP status code reachable viaerrors.Asfrom any caller"HTTPStatus=N Error: result_code, message=..."matching the existing non-JSON path formatPOST Error:wrapper switches fromerrors.New("POST Error: " + msg)tofmt.Errorf("POST Error: %w", err)so the*KeeperHTTPErrorstays in the chainCallers can now branch on status programmatically:
Breaking Change
err.Error()on the JSON-error path now includesHTTPStatus=Nas a prefix. Code that string-matched"POST Error: Error: access_denied, ..."will no longer match. Migrate toerrors.As. See CHANGELOG.md for the migration snippet.Related Issues
Closes KSM-919
Part of v1.7.0 release (PR #51)