rgw/admin: expose HTTP status code on admin API errors #1362
All Vouch review confidence checks passed
Residual risk 0.16 = Change Risk (0.40) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.40 · 307 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.343
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #1362"
general
weight: 0.35
phlogistonjohn
Summary
The RGW admin API client discards the HTTP status code of a failed request. In
(API).call, a non-2xx response becomes an error built from only the responsebody, and the resulting error type is unexported. Callers therefore cannot
inspect the HTTP status except by string-matching the response
Code— brittlein practice, since RadosGW reports several internal conditions as HTTP 500 with
body
{"Code":"UnknownError"}(e.g. an optimistic-concurrency collision whenmultiple keys/subusers of the same user are modified concurrently), and
"UnknownError"is not a go-ceph error constant.Change
Following the review discussion, the internal
statusErrortype stays privateand a preview public type is added instead of exporting it directly:
StatusError(behind//go:build ceph_preview) exposingStatusCode,retrievable with
errors.As. The error code remains private, reachable asbefore through the error text and sentinel matching (
errors.Is).statusErrorkeeps its HTTP status internally and gains anAsmethod (alsopreview) that converts to
StatusError, so internal fields that were notmeant to be public are not exposed.
(API).callnow passesresp.StatusCodeintohandleStatusError, and thestatus is preserved via
errors.Joinon both the JSON-decode failure path andthe
io.ReadAllfailure path, so callers can still inspect it.Backward compatible:
errors.Is(err, admin.ErrNoSuchUser)(and the otherErrXxxsentinels) keeps working.Testing
TestHandleStatusError(non-preview) updated for the newhandleStatusErrorsignature.
TestGetUserStatusError(preview) uses the mock client to return a500 UnknownErrorand verifies the status propagates throughcall()and isretrievable via
errors.As.404 NoSuchUseryields
StatusCode:404(anderrors.Is(ErrNoSuchUser)still true), and aconcurrent
RemoveKeycollision yieldsStatusCode:500.make api-updaterecordsStatusError.ErrorandStatusError.Isas previewAPI; builds,
go vetandgofmtpass with and withoutceph_preview.Checklist
//go:build ceph_previewmake api-updateto record new APIs