← Back to Pull requests

rgw/admin: expose HTTP status code on admin API errors #1362

Closed
unknown closed this pull request without merging on Nov 11, 2026 16:16 UTC
View on GitHub
unknown unknown commented on Oct 30, 2026 12:32 UTC
Author

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 response
body, and the resulting error type is unexported. Callers therefore cannot
inspect the HTTP status except by string-matching the response Code — brittle
in practice, since RadosGW reports several internal conditions as HTTP 500 with
body {"Code":"UnknownError"} (e.g. an optimistic-concurrency collision when
multiple 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 statusError type stays private
and a preview public type is added instead of exporting it directly:

  • Add StatusError (behind //go:build ceph_preview) exposing StatusCode,

  • retrievable with errors.As. The error code remains private, reachable as
    before through the error text and sentinel matching (errors.Is).
  • statusError keeps its HTTP status internally and gains an As method (also

  • preview) that converts to StatusError, so internal fields that were not
    meant to be public are not exposed.
  • (API).call now passes resp.StatusCode into handleStatusError, and the

  • status is preserved via errors.Join on both the JSON-decode failure path and
    the io.ReadAll failure path, so callers can still inspect it.

    Backward compatible: errors.Is(err, admin.ErrNoSuchUser) (and the other
    ErrXxx sentinels) keeps working.

    Testing

  • TestHandleStatusError (non-preview) updated for the new handleStatusError

  • signature.
  • TestGetUserStatusError (preview) uses the mock client to return a

  • 500 UnknownError and verifies the status propagates through call() and is
    retrievable via errors.As.
  • Verified against a live RadosGW (Ceph 21.2.0) cluster: a 404 NoSuchUser

  • yields StatusCode:404 (and errors.Is(ErrNoSuchUser) still true), and a
    concurrent RemoveKey collision yields StatusCode:500.
  • make api-update records StatusError.Error and StatusError.Is as preview

  • API; builds, go vet and gofmt pass with and without ceph_preview.

    Checklist


  • Added tests for features and functional changes

  • Public functions and types are documented

  • Standard formatting is applied to Go code

  • Is this a new API? Added behind //go:build ceph_preview

  • Ran make api-update to record new APIs
  • Diff: 307 lines (+230 / -77) across 3 files Reviewer: phlogistonjohn Review duration: 17503m
    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
    0.40
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 40.2% (MEDIUM) · Higher = larger blast radius
    40.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 15.9% · Safe to merge
    15.9%
    Repository