Skip to content

SWF(bug): reject huge request timeouts without panicking - #16

Merged
maplepaladin73 merged 1 commit into
mainfrom
devin/1794945050-timeout-overflow
Nov 22, 2026
Merged

maplepaladin73 merged 1 commit into
mainfrom
devin/1794945050-timeout-overflow

Conversation

@maplepaladin73

@maplepaladin73 maplepaladin73 commented Nov 17, 2026 •

Copy link
Copy Markdown
Owner

Reject unrepresentable request timeouts with HTTP 400 instead of panicking.

Summary

Use fallible duration conversion and checked deadline addition in the shared helper; propagate errors through all callers without disabling deadlines.

Test plan

Failing run, regression tests added before the fix:

running 2 tests
unrepresentable_timeout_instant_is_rejected_before_dispatch ... FAILED
  overflow when adding duration to instant
unrepresentable_timeout_duration_is_rejected_before_dispatch ... FAILED
  cannot convert float seconds to Duration: value is either too big or NaN
test result: FAILED. 0 passed; 2 failed

Passing run after the fix, same test filter:

running 3 tests
non_finite_or_unrepresentable_timeout_is_an_error ... ok
unrepresentable_timeout_instant_is_rejected_before_dispatch ... ok
unrepresentable_timeout_duration_is_rejected_before_dispatch ... ok
test result: ok. 3 passed; 0 failed

The two HTTP-handler regressions deserialize valid JSON (timeout: 1e30 / 1e19), exercise chat and legacy completions in both blocking and streaming modes, and assert HTTP 400, an OpenAI error envelope, and no scheduler dispatch. Helper tests retain zero/negative disabling and positive/fractional budgets, and reject NaN/infinity.

  • Full spark binary suite: 3150 passed, 0 failed, 14 ignored.
  • Blueprint test (cargo test -p atlas-core --lib with the environment below): 218 passed.
  • Blueprint lint, exit 0:
    cargo fmt --all -- --check && ATLAS_SKIP_BUILD=1 CUDARC_CUDA_VERSION=13000 cargo clippy --workspace --tests && bash scripts/check-license-headers.sh && typos
    License engine: 4177 files checked, 0 invalid.
  • ATLAS_SKIP_BUILD=1 CUDARC_CUDA_VERSION=13000 cargo doc --workspace --no-deps.
  • Added regression tests; ran production handlers using the repository's GPU-free stubs (bash scripts/ci_gpu_stubs.sh).
  • Devin Review: zero findings; all available PR checks passed.
  • Extra full-workspace run: 13 existing spark-model video tests failed because this VM's FFmpeg 4.4.2 rejects -fps_mode; confirmed directly with FFmpeg. Server tests are unaffected; no unrelated code changed.
  • Real-model/GPU validation and Docker image rebuild: not run on this GPU-free VM. No live HTTP listener or inference benchmark was exercised.

Notes for reviewers

Root cause: finite JSON values still exceed Rust's time representations. 1e30 fits the wire's f32 but panics in Duration::from_secs_f32; 1e19 fits a duration but panics in unchecked Instant addition. Checking only finiteness or only the conversion misses a panic. try_from_secs_f32 plus checked_add guards both operations at their single source of truth, preserving ordinary budgets and the non-positive-disable contract. The scoring caller also handles an unrepresentable server timeout as a server error before enqueueing work.

Try it: ATLAS_SKIP_BUILD=1 CUDARC_CUDA_VERSION=13000 cargo test -p spark-server --bin spark unrepresentable_timeout -- --nocapture

Benchmarks: not applicable; this fixes request validation, not inference performance.

Authorship: AI-authored by Devin.

CLA

  • Maintainer CLA confirmation, if required.

Software Factory opened this PR for Robert
Implemented in session Stop huge request timeout panicking deadline helper
Review with Devin · Open in Devin Desktop


@devin-ai-integration

Copy link
Copy Markdown

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@devin-ai-integration

Copy link
Copy Markdown

PR #16 GPU validation: PASS

PR head: 46443d5428fbc7b7156517bbcaa5ccd0e676aed7; local gpu-pr16 = PR head + the two conflict-free GPU shims. No source edits/push/comments.
Hardware/launch: RTX 5090 sm_120 via local rtx5090 shim, Holo-3.1-4B BF16 checkpoint with runtime NVFP4 conversion; identical flags/environment to pr12-result.md / serve-sm120.sh, including --dangerously-allow-unresolved-kernel-lookups for the missing optional w4a16 k16 variant. Robert's processes untouched.

Build: ~/repos/build-sm120.sh ~/repos/atlas-sm120; launch: ~/repos/serve-sm120.sh pr16. Build exited 0 and health became ready (logs build-pr16.log, serve-pr16.log).

Live timeout=1e30 and 1e19 return HTTP 400/OpenAI errors on chat and legacy completions, blocking and streaming; valid timeout=10 still generates. CUDA timeout tests cover duration/instant overflow, finite/NaN helper validation and ordinary budgets. No main overflow reproduction: that would deliberately panic its request path. Score endpoint/server-timeout misconfiguration not exercised live.

PR regression tests (CUDA build)

PATH=/home/robert/.cargo/bin:$PATH CUDA_HOME=/home/robert/atlas-x86-probe/cuda-home ATLAS_TARGET_HW=rtx5090 ATLAS_TARGET_MODEL=holo-3.1-4b ATLAS_TARGET_QUANT=nvfp4 ATLAS_PREDICTOR_ARCH=sm_120 ATLAS_NO_RDMA=1 CUDARC_CUDA_VERSION=12090 LD_LIBRARY_PATH=/usr/local/cuda-12.9/lib64 cargo test --release -p spark-server --bin spark --no-default-features --features cuda --target-dir /home/robert/repos/atlas-target-sm120 timeout
running 10 tests
test api::chat_stream::handle_done::wire_finish_reason_tests::timeout_and_tool_overrides_keep_their_rank ... ok
test main_modules::app_state::tests::non_finite_or_unrepresentable_timeout_is_an_error ... ok
test main_modules::app_state::tests::positive_timeout_yields_that_budget ... ok
test main_modules::app_state::tests::zero_timeout_disables_the_deadline ... ok
test openai::tests::completions::completion_request_deserializes_timeout_override ... ok
test scheduler::lifecycle_tests::timeout_unchanged_and_still_outranks_everything ... ok
test scheduler::lifecycle_tests::token_derived_stops_outrank_non_timeout_guards ... ok
test api::refusal_content_tests::blocking_refusal_preserves_length_and_timeout_finish_reasons ... ok
test api::completions_exec::spec_policy_tests::unrepresentable_timeout_duration_is_rejected_before_dispatch ... ok
test api::completions_exec::spec_policy_tests::unrepresentable_timeout_instant_is_rejected_before_dispatch ... ok
test result: ok. 10 passed; 0 failed; 0 ignored; 0 measured; 3149 filtered out; finished in 0.00s

No GPU stub script run; full suite/lints not repeated for this validation-only step. Raw HTTP bodies/headers are adjacent pr16-*.out / .headers.

chat

curl -sSN --max-time 90 -D /home/robert/repos/gpu-logs/pr16-chat.headers -o /home/robert/repos/gpu-logs/pr16-chat.out -w '%{http_code}' http://127.0.0.1:8897/v1/chat/completions -H 'content-type: application/json' -d '{"model": "holo", "messages": [{"role": "user", "content": "What is the capital of France? One sentence."}], "max_tokens": 256, "temperature": 0, "enable_thinking": false}'

HTTP 200

The capital of France is Paris.

stream

curl -sSN --max-time 90 -D /home/robert/repos/gpu-logs/pr16-stream.headers -o /home/robert/repos/gpu-logs/pr16-stream.out -w '%{http_code}' http://127.0.0.1:8897/v1/completions -H 'content-type: application/json' -d '{"model": "holo", "prompt": "The capital of France is", "max_tokens": 12, "temperature": 0, "stream": true, "stop": ["\n"]}'

HTTP 200

' Paris.'; 3 valid JSON frames; [DONE]=True

responses

curl -sSN --max-time 90 -D /home/robert/repos/gpu-logs/pr16-responses.headers -o /home/robert/repos/gpu-logs/pr16-responses.out -w '%{http_code}' http://127.0.0.1:8897/v1/responses -H 'content-type: application/json' -d '{"model": "holo", "input": "What is the capital of France? One sentence.", "max_output_tokens": 200, "temperature": 0, "reasoning": {"effort": "none"}}'

HTTP 200

status=completed; The capital of France is Paris.

timeout-1e+30-False-False

curl -sSN --max-time 90 -D /home/robert/repos/gpu-logs/pr16-timeout-1e+30-False-False.headers -o /home/robert/repos/gpu-logs/pr16-timeout-1e+30-False-False.out -w '%{http_code}' http://127.0.0.1:8897/v1/completions -H 'content-type: application/json' -d '{"model": "holo", "prompt": "Hello", "max_tokens": 1, "timeout": 1e+30, "stream": false}'

HTTP 400

{'message': 'timeout must be finite and fit in a duration', 'type': 'invalid_request_error', 'param': None, 'code': None, 'hint': None}

timeout-1e+30-False-True

curl -sSN --max-time 90 -D /home/robert/repos/gpu-logs/pr16-timeout-1e+30-False-True.headers -o /home/robert/repos/gpu-logs/pr16-timeout-1e+30-False-True.out -w '%{http_code}' http://127.0.0.1:8897/v1/chat/completions -H 'content-type: application/json' -d '{"model": "holo", "messages": [{"role": "user", "content": "Hello"}], "max_tokens": 256, "temperature": 0, "enable_thinking": false, "timeout": 1e+30, "stream": false}'

HTTP 400

{'message': 'timeout must be finite and fit in a duration', 'type': 'invalid_request_error', 'param': None, 'code': None, 'hint': None}

timeout-1e+19-False-False

curl -sSN --max-time 90 -D /home/robert/repos/gpu-logs/pr16-timeout-1e+19-False-False.headers -o /home/robert/repos/gpu-logs/pr16-timeout-1e+19-False-False.out -w '%{http_code}' http://127.0.0.1:8897/v1/completions -H 'content-type: application/json' -d '{"model": "holo", "prompt": "Hello", "max_tokens": 1, "timeout": 1e+19, "stream": false}'

HTTP 400

{'message': 'timeout is too large to represent a deadline', 'type': 'invalid_request_error', 'param': None, 'code': None, 'hint': None}

timeout-1e+19-False-True

curl -sSN --max-time 90 -D /home/robert/repos/gpu-logs/pr16-timeout-1e+19-False-True.headers -o /home/robert/repos/gpu-logs/pr16-timeout-1e+19-False-True.out -w '%{http_code}' http://127.0.0.1:8897/v1/chat/completions -H 'content-type: application/json' -d '{"model": "holo", "messages": [{"role": "user", "content": "Hello"}], "max_tokens": 256, "temperature": 0, "enable_thinking": false, "timeout": 1e+19, "stream": false}'

HTTP 400

{'message': 'timeout is too large to represent a deadline', 'type': 'invalid_request_error', 'param': None, 'code': None, 'hint': None}

timeout-1e+30-True-False

curl -sSN --max-time 90 -D /home/robert/repos/gpu-logs/pr16-timeout-1e+30-True-False.headers -o /home/robert/repos/gpu-logs/pr16-timeout-1e+30-True-False.out -w '%{http_code}' http://127.0.0.1:8897/v1/completions -H 'content-type: application/json' -d '{"model": "holo", "prompt": "Hello", "max_tokens": 1, "timeout": 1e+30, "stream": true}'

HTTP 400

{'message': 'timeout must be finite and fit in a duration', 'type': 'invalid_request_error', 'param': None, 'code': None, 'hint': None}

timeout-1e+30-True-True

curl -sSN --max-time 90 -D /home/robert/repos/gpu-logs/pr16-timeout-1e+30-True-True.headers -o /home/robert/repos/gpu-logs/pr16-timeout-1e+30-True-True.out -w '%{http_code}' http://127.0.0.1:8897/v1/chat/completions -H 'content-type: application/json' -d '{"model": "holo", "messages": [{"role": "user", "content": "Hello"}], "max_tokens": 256, "temperature": 0, "enable_thinking": false, "timeout": 1e+30, "stream": true}'

HTTP 400

{'message': 'timeout must be finite and fit in a duration', 'type': 'invalid_request_error', 'param': None, 'code': None, 'hint': None}

timeout-1e+19-True-False

curl -sSN --max-time 90 -D /home/robert/repos/gpu-logs/pr16-timeout-1e+19-True-False.headers -o /home/robert/repos/gpu-logs/pr16-timeout-1e+19-True-False.out -w '%{http_code}' http://127.0.0.1:8897/v1/completions -H 'content-type: application/json' -d '{"model": "holo", "prompt": "Hello", "max_tokens": 1, "timeout": 1e+19, "stream": true}'

HTTP 400

{'message': 'timeout is too large to represent a deadline', 'type': 'invalid_request_error', 'param': None, 'code': None, 'hint': None}

timeout-1e+19-True-True

curl -sSN --max-time 90 -D /home/robert/repos/gpu-logs/pr16-timeout-1e+19-True-True.headers -o /home/robert/repos/gpu-logs/pr16-timeout-1e+19-True-True.out -w '%{http_code}' http://127.0.0.1:8897/v1/chat/completions -H 'content-type: application/json' -d '{"model": "holo", "messages": [{"role": "user", "content": "Hello"}], "max_tokens": 256, "temperature": 0, "enable_thinking": false, "timeout": 1e+19, "stream": true}'

HTTP 400

{'message': 'timeout is too large to represent a deadline', 'type': 'invalid_request_error', 'param': None, 'code': None, 'hint': None}

valid-timeout

curl -sSN --max-time 90 -D /home/robert/repos/gpu-logs/pr16-valid-timeout.headers -o /home/robert/repos/gpu-logs/pr16-valid-timeout.out -w '%{http_code}' http://127.0.0.1:8897/v1/completions -H 'content-type: application/json' -d '{"model": "holo", "prompt": "The capital of France is", "max_tokens": 4, "timeout": 10, "temperature": 0}'

HTTP 200

Paris.
A
Live assertions: PASS

@devin-ai-integration
devin-ai-integration Bot force-pushed the devin/1794945050-timeout-overflow branch from 46443d5 to 09ec12b Compare November 22, 2026 13:55
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration
devin-ai-integration Bot force-pushed the devin/1794945050-timeout-overflow branch from 09ec12b to e200b9a Compare November 22, 2026 13:56
@maplepaladin73
maplepaladin73 merged commit 81bd68a into main Nov 22, 2026
1 check was pending
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant