Skip to content

serve: an error about one request field names it in param - #998

Merged
juliankang4 merged 2 commits into
midagedev:mainfrom
juliankang4:dgx-spark-q38-usab-error-param
Oct 30, 2026
Merged

juliankang4 merged 2 commits into
midagedev:mainfrom
juliankang4:dgx-spark-q38-usab-error-param

Conversation

@juliankang4

Copy link
Copy Markdown
Collaborator

chat completions 계열 경로의 400 오류가 문제의 요청 필드를 param으로 알려 주도록 고치고, 릴리스 압축 파일에 API 레퍼런스(docs/serving.md)를 넣었습니다.

What and why

A 400 from a chat completions or responses route about one request field now carries param, the field's top-level name, beside the code, message and type it already had. A client can read the field instead of parsing the message. A fault inside a field names the field that holds it (messages for messages[2].content), and a constraint the compiler refuses (response_format, text, tools) keeps the compiler's own message and names its source field. /v1/responses names its own fields (input, text, reasoning) where the chat body it runs as names others. An error about no single field (a body that is not JSON, a prompt past the context, a full queue) carries none, and the /v1/messages envelope keeps its object without it. docs/serving.md states the rule.

The second commit makes build.sh and build-mac.sh copy docs/serving.md beside LICENSE, and each archive's README names it, so the routes, request fields and error objects read offline.

The change is in the request parsing and error path of the server (crates/serve, crates/embed/src/request.rs). No kernel or generation path changes.

Release notes: Changed: a 400 from a chat completions or responses route about one request field names it in param, and the release archives carry docs/serving.md.

Code shape

  • No second copy. The compile-error cases share the one request boundary (schema::request) that already owns the three constraint compiles; no helper was added.
  • Model code holds only architecture facts. The change is in the common server and request code; no model file changed.
  • Dead code is gone. Nothing was made unused.
  • No silent failure. A compiler failure keeps its message and gains its source field; none is dropped or defaulted.
  • Comments state what is true now. docs/serving.md states the param contract the code now meets.
  • No relaxed gate. No band, tolerance or lint moved.
  • cargo fmt and cargo clippy are clean on what I touched; the lint count did not go up.

Duplication found or removed (path:line), or "none": none.

What I ran

Before the fix, the stop-id unit test and the error-envelope table test (hw_errors_are_openai_objects) with the new cases failed on the missing param:

test constrain::tests::a_stop_text_in_the_program_is_refused_by_name ... FAILED
  left: None
 right: Some("response_format.json_schema.schema")
test hw_errors_are_openai_objects ... FAILED
  left: None
 right: Some("response_format")

The empty-prompt cases failed on it too:

assertion `left == right` failed: {"code":400,"message":"the prompt is empty","type":"invalid_request_error"}
  left: None
 right: Some("prompt")

With the change, on a base of 977e8e74d47c59b00f7672421eecf0a4c32b30d3:

cargo fmt --all -- --check
cargo test -j 2 -p bloomery-serve --lib a_stop_text_in_the_program_is_refused_by_name -- --exact constrain::tests::a_stop_text_in_the_program_is_refused_by_name --test-threads=1
cargo test -j 2 -p bloomery-serve --test serve hw_errors_are_openai_objects -- --ignored --exact --test-threads=1
test constrain::tests::a_stop_text_in_the_program_is_refused_by_name ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 428 filtered out; finished in 0.00s
test hw_errors_are_openai_objects ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 110 filtered out; finished in 10.60s

cargo fmt --all -- --check exits 0.

The real binary on a DGX Spark, serving Qwen3.8-Flash-Next FP4 (nvidia__Qwen3.8-Flash-Next-FP4-Local), built for sm_121a with the release feature set of tools/release/build.sh:

./target/release/bloomery-serve -m <model folder> --host 127.0.0.1 --port 18742 --ctx-size 2048

Requests against it, each answering 400 with the field named:

POST /v1/chat/completions {"model": "qwen3.8"} -> 400 {"error": {"code": 400, "message": "'messages' is required and must be an array", "type": "invalid_request_error", "param": "messages"}}
POST /v1/chat/completions {..., "temperature": "hot"} -> 400 {"error": {"code": 400, "message": "temperature must be a number, not a string", "type": "invalid_request_error", "param": "temperature"}}
POST /completion {"prompt": 7} -> 400 {"error": {"code": 400, "message": "'prompt' must be a string or an array of tokens", "type": "invalid_request_error", "param": "prompt"}}
POST /v1/responses {"model": "qwen3.8", "input": 5, "store": false} -> 400 {"error": {"code": 400, "message": "input must be a string or an array of items, not a number", "type": "invalid_request_error", "param": "input"}}
POST /v1/chat/completions "{not json" -> 400 {"error": {"code": 400, "message": "invalid JSON body: key must be a string at line 1 column 2", "type": "invalid_request_error"}}

The gate prints ERROR-PARAM PASS.

AI help

AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.

@github-actions github-actions Bot added documentation Improvements or additions to documentation serve The HTTP server: crates/serve tools Tools, recipes, CI and the toolchain: tools/, justfile, .github/, Cargo labels Oct 30, 2026
github-actions[bot]
github-actions Bot previously approved these changes Oct 30, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Verdict: CLEAN: The changed request validation, error serialization and release packaging have no surviving must-fix finding.

Checked

Duplicates: 5 new functions checked against existing owners; none duplicated. Dryer reported 0 candidate pairs.
Complexity: gen_params rose from 41 to 43 through field attribution in its existing constraint-error branch; no new request behavior branch.
Silent failure: 5 metadata fallback sites followed through JSON and SSE consumers; invalid inputs retain their errors.
Tests (static mutation analysis): removing compiler source attribution at crates/serve/src/constrain/schema.rs:925 fails the stop-text unit test and the error-envelope table. Removing media attribution at crates/serve/src/api.rs:3500 fails the media-error unit test. Dropping input attribution at crates/serve/src/embeddings.rs:562 fails the embedding-input test. Removing Responses renaming at crates/serve/src/responses.rs:254 fails the image-conversion test and envelope table. Dropping empty-prompt attribution at crates/serve/src/api.rs:4130 fails the table. Adding param to the Anthropic envelope at crates/serve/src/anthropic.rs:893 fails its vision-error comparison.
Gates: no threshold, tolerance, lint level or test case removed or relaxed; the PR supplies failure-first output for the new metadata assertions.
Escape catalog: no C1–C4 pattern introduced. Both changed release scripts passed bash -n.
Performance: changes affect request validation, error handling and packaging; no decode or prefill-loop work changes.

Notes

Rust tests were not run in this review. The PR reports two targeted test passes, not a full gate-serve run.

🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)

Every 400 an OpenAI route answers about one request field carries `param`, the field's top-level name, beside llama-server's code, message and type. /v1/responses names its own fields (input, text, reasoning) where the chat body it runs as names others. An error about no single field carries none, and the Anthropic envelope keeps its object without it. docs/serving.md states the rule.
build.sh and build-mac.sh copy docs/serving.md beside LICENSE, and each archive's README names it, so the routes, request fields and error objects read offline.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since the last review: no earlier must-fix or non-blocking items were open.

Verdict: CLEAN: The rebase preserves the shared 404 constructor and its error envelope.

Checked

Duplicates: 0 new definitions in the interdiff. Both functions in the dryer pair were read; invalid and not_found own different status/type pairs.
Complexity: crapper reports gen_params 41 → 43 from field attribution in an existing error branch. That patch is unchanged since the previous review.
Silent failure: 1 metadata initialization followed through serialization. param: None omits metadata; unknown routes, unknown models and missing stored responses still return named 404 errors.
Tests: no test changed in the interdiff. Static mutation check: changing param: None at crates/serve/src/api.rs:1561 to Some("model".to_owned()) fails the /nope assertion in hw_errors_are_openai_objects.
Gates: no gate, case, tolerance or lint changed in the interdiff.
Escape catalog: no C1–C4 pattern matched.
Performance: the interdiff changes error construction and imports; no decode or prefill hot path changes.

Notes

Rust tests were not run in this review. The PR reports targeted test passes, not a full gate-serve run.

🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)

@juliankang4

Copy link
Copy Markdown
Collaborator Author

The review is done and the contribution check passed, so I'm merging this.

@juliankang4
juliankang4 merged commit dd93435 into midagedev:main Oct 30, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation serve The HTTP server: crates/serve tools Tools, recipes, CI and the toolchain: tools/, justfile, .github/, Cargo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant