Skip to content

SWF(bug): allow DELETE in the server's CORS preflight - #55

Merged
maplepaladin73 merged 1 commit into
mainfrom
devin/1795378308-cors-allow-delete
Nov 22, 2026
Merged

maplepaladin73 merged 1 commit into
mainfrom
devin/1795378308-cors-allow-delete

Conversation

@maplepaladin73

@maplepaladin73 maplepaladin73 commented Nov 22, 2026 •

Copy link
Copy Markdown
Owner

Summary

Browsers could not call any of spark-server's DELETE endpoints cross-origin: the CORS preflight now allows DELETE.

Root cause: build_and_serve in serve_router.rs built its CorsLayer with allow_methods([GET, POST, OPTIONS]), but the router registers DELETE routes (/v1/responses/{id}, /v1/conversations/{id}, /v1/conversations/{id}/items/{item_id}, batches, files). A browser's OPTIONS preflight for DELETE got access-control-allow-methods: GET,POST,OPTIONS, so the browser blocked the actual request. Fix: add Method::DELETE, with the layer moved into a cors_layer() helper so the test exercises the exact production layer.

Test plan

Regression test main_modules::serve_router::tests::cors_preflight_allows_delete sends a real preflight (Origin + Access-Control-Request-Method: DELETE) through cors_layer().

Before the fix (fails):

test main_modules::serve_router::tests::cors_preflight_allows_delete ... FAILED
DELETE missing from access-control-allow-methods: GET,POST,OPTIONS
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 3233 filtered out

After the fix (passes):

test main_modules::serve_router::tests::cors_preflight_allows_delete ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 3233 filtered out

Full spark binary suite: test result: ok. 3220 passed; 0 failed; 14 ignored.

Live check against the real spark serve binary (no model, GPU-free):

access-control-allow-methods
Before GET,POST,OPTIONS
After GET,POST,DELETE,OPTIONS

Try it (with spark serve --port 18080 running):

curl -si -X OPTIONS http://127.0.0.1:18080/v1/conversations/abc -H 'Origin: http://example.com' -H 'Access-Control-Request-Method: DELETE' | grep -i access-control-allow-methods
  • cargo fmt --all -- --check
  • ATLAS_SKIP_BUILD=1 CUDARC_CUDA_VERSION=13000 cargo clippy --workspace --tests
  • bash scripts/check-license-headers.sh
  • typos
  • Tested against a real model / hardware — not applicable (HTTP layer only); not run on GPU
  • Added or updated tests where applicable

Notes for reviewers

Untested: an actual browser fetch(..., {method: 'DELETE'}) from another origin (verified via the preflight headers only), and GPU/model serving.

CLA


Software Factory opened this PR for Robert
Implemented in session Allow DELETE in the server's CORS preflight
Review with Devin · Open in Devin Desktop


Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@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

@maplepaladin73
maplepaladin73 merged commit 8ab3b51 into main Nov 22, 2026
1 check passed
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