Skip to content

refactor error responses into shared utils::response helpers - #33894

Merged
sherlockwu merged 2 commits into
mainfrom
rainj-me/rust-server-error-response
Aug 13, 2026
Merged

sherlockwu merged 2 commits into
mainfrom
rainj-me/rust-server-error-response

Conversation

@rainj-me

@rainj-me rainj-me commented Aug 6, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation

Modifications

Accuracy Tests

Speed Tests and Profiling

Checklist

Review and Merge Process

  1. Ping Merge Oncalls to start the process. See the PR Merge Process.
  2. Get approvals from CODEOWNERS and other reviewers.
  3. Trigger CI tests with comments or contact authorized users to do so.
    • Common commands include /tag-and-rerun-ci, /tag-run-ci-label, /rerun-failed-ci
  4. After green CI and required approvals, ask Merge Oncalls or people with Write permission to merge the PR.

CI States

Latest PR Test (Base): ✅ Run #31678306810
Latest PR Test (Extra): ❌ Run #31678306585

@rainj-me rainj-me added the run-ci CI: run the baseline test suite on this PR label Aug 6, 2026
@rainj-me
rainj-me requested a review from sherlockwu August 6, 2026 18:27
@rainj-me
rainj-me marked this pull request as ready for review August 6, 2026 18:32
Err(rejection) => {
return error_response(
StatusCode::BAD_REQUEST,
error_payload(StatusCode::BAD_REQUEST, rejection.body_text()),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can we have a thin wrapper (one native, one OpenAI) so the status code don't need to be typed twice per call site? like

// native side
pub fn native_error(code: StatusCode, message: &str, stream: bool) -> Response {
    error_response(code, error_value(code.as_u16(), message), stream)
}

// openai side (in openai.rs)
fn openai_error(code: StatusCode, message: impl Into<String>, stream: bool) -> Response {
    error_response(code, error_payload(code, message), stream)
}

@rainj-me
rainj-me force-pushed the rainj-me/rust-server-error-response branch 2 times, most recently from 5afb2ab to 53a0cfe Compare August 12, 2026 18:14
Unify the native and OpenAI error paths on one error_response /
error_value / sse_error_response set in utils::response: frame.rs
loses its private error_value, submit.rs loses pre_submit_error,
and the OpenAI frontend loses openai_error / openai_error_response /
streaming_error in favor of the shared shaping plus its own
error_payload body builder.
@sherlockwu
sherlockwu force-pushed the rainj-me/rust-server-error-response branch from 53a0cfe to 3fc94ee Compare August 13, 2026 07:34
@sherlockwu
sherlockwu merged commit fd1e04d into main Aug 13, 2026
93 of 97 checks passed
@sherlockwu
sherlockwu deleted the rainj-me/rust-server-error-response branch August 13, 2026 08:30
Atituiset pushed a commit to Atituiset/sglang that referenced this pull request Sep 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run-ci CI: run the baseline test suite on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants