Summary
The server's /schema upload path enforces MAX_UPLOAD_BYTES (50 MiB) and rejects oversized files with 413 PAYLOAD_TOO_LARGE (xazz-server/src/main.rs ~line 501), but this behavior has no test. A regression could silently allow unbounded uploads (disk DoS).
Context
- Constant:
MAX_UPLOAD_BYTES in xazz-server/src/main.rs.
- Handler:
handle_schema reads the multipart field, checks data.len() > MAX_UPLOAD_BYTES, and returns (StatusCode::PAYLOAD_TOO_LARGE, ...).
- Existing tests in
#[cfg(test)] mod tests call handlers directly (see handle_execute tests) — no HTTP server is needed.
- The
axum Multipart extractor is the hard part: you can build a Multipart from a reqwest::multipart-style body, or test the size check by extracting the reusable validation into a helper function that takes &[u8] and asserting on that helper directly.
Task
Add a test that proves an upload larger than MAX_UPLOAD_BYTES is rejected with 413. Two acceptable approaches:
- Preferred: extract the size-check into a small pure helper (e.g.
fn validate_upload_size(len: usize) -> Result<(), StatusCode>) used by handle_schema, and unit-test it with MAX_UPLOAD_BYTES and MAX_UPLOAD_BYTES + 1.
- Or build a real multipart body and invoke
handle_schema with it.
Definition of Done
- A test named something like
oversized_upload_is_rejected passes.
- Boundary covered:
== MAX_UPLOAD_BYTES allowed, +1 rejected.
cargo test -p xazz-server passes; cargo fmt --all -- --check clean.
Notes
- This is the server crate; it links tokio/axum, so builds are a bit heavier than
xazz-compiler, but cargo test -p xazz-server is the scope.
- User-facing error strings in the handler are English; if you add any, keep them English.
Summary
The server's
/schemaupload path enforcesMAX_UPLOAD_BYTES(50 MiB) and rejects oversized files with413 PAYLOAD_TOO_LARGE(xazz-server/src/main.rs~line 501), but this behavior has no test. A regression could silently allow unbounded uploads (disk DoS).Context
MAX_UPLOAD_BYTESinxazz-server/src/main.rs.handle_schemareads the multipart field, checksdata.len() > MAX_UPLOAD_BYTES, and returns(StatusCode::PAYLOAD_TOO_LARGE, ...).#[cfg(test)] mod testscall handlers directly (seehandle_executetests) — no HTTP server is needed.axumMultipartextractor is the hard part: you can build aMultipartfrom areqwest::multipart-style body, or test the size check by extracting the reusable validation into a helper function that takes&[u8]and asserting on that helper directly.Task
Add a test that proves an upload larger than
MAX_UPLOAD_BYTESis rejected with413. Two acceptable approaches:fn validate_upload_size(len: usize) -> Result<(), StatusCode>) used byhandle_schema, and unit-test it withMAX_UPLOAD_BYTESandMAX_UPLOAD_BYTES + 1.handle_schemawith it.Definition of Done
oversized_upload_is_rejectedpasses.== MAX_UPLOAD_BYTESallowed,+1rejected.cargo test -p xazz-serverpasses;cargo fmt --all -- --checkclean.Notes
xazz-compiler, butcargo test -p xazz-serveris the scope.