flm serve crashes when a request is missing a required field (`POST {}`)
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 68/100
Hướng nghiên cứu
Start in src/server/rest_handler.cpp at the listed handle_show, handle_generate, handle_chat, handle_embeddings, handle_openai_chat_completion, and handle_openai_completion call sites, then inspect server.cpp:736. Run the server-api conformance tests in specs/server-api/tests/ or reproduce POST {} against the named endpoints. Done means missing required fields receive HTTP 400 responses naming the field, and a subsequent normal chat request still completes.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
What happens
A request body that lacks a required field kills the flm serve process. No response is sent, and every later connection is refused until the server is restarted.
flm serve llama3.2:1b
curl -s -w '\nHTTP %{http_code}\n' http://127.0.0.1:52625/api/show \
-H 'Content-Type: application/json' -d '{}'
# curl exit 56, HTTP 000; the flm process is gone
curl -s http://127.0.0.1:52625/v1/models
# connection refused
We saw the same crash with POST {} on /api/show, /api/generate and /v1/chat/completions, each tested in isolation. /api/chat and /v1/completions read their required field the same way, but we did not isolate them.
The same pattern explains a milder symptom. When /v1/embeddings gets no model, the handler happens to survive, and it answers HTTP 200 with {"error":"[json.exception.type_error.302] type must be string, but is invalid"}. The value it read was garbage, not a missing-key error.
Expected
A 400 naming the missing field, and the server keeps serving.
Cause
The handlers take const json& request and read required fields with operator[]:
handle_show:rest_handler.cpp:612request["model"]handle_generate::650request["prompt"]handle_chat::764request["messages"]handle_embeddings::882-889request["model"],request["input"]handle_openai_chat_completion::1103request["messages"]handle_openai_completion::1410request["prompt"]
On a const nlohmann::json, operator[] with a missing key is undefined behaviour. It is guarded only by JSON_ASSERT, which a release build compiles out, so it does not throw, and the surrounding try/catch never runs. The handler dereferences the map's end iterator instead.
Fix we are carrying
Check presence and type before each read, and refuse with a 400:
https://github.com/noamsto/nix-amd-ai/blob/46d7a73c1044435cec0ff08410e1a3bc87cbc544/pkgs/fastflowlm/patches/request-validation.patch
The require_field() helper is ported from OpenFlowLM-Next (src/server/openai_compat.hpp, Vegard Berget). Its error bodies carry an OpenAI-style string code ("missing_required_parameter"). Upstream send_response reads error.code with .get<int>() (server.cpp:736), which would throw on a string code. So the helper needs that line changed too. Our version of that change is in server-error-handling.patch in the same directory.
After the patch, all five endpoints answer POST {} with a 400 naming the field, and a normal chat request afterwards still completes. OpenFlowLM-Next's specs/server-api/tests/test_request_validation.py went from 0 of 22 passing to 14 passing with 8 skipped.
Environment
FLM v1.0.6 built from the tag, plus one downstream patch that only changes how send_response maps error.code to an HTTP status. That patch does not touch these read paths.
Ryzen AI MAX+ 395 (Strix Halo), XDNA2 NPU, 8 columns. NixOS, Linux 7.2.8, amdxdna 0.10, NPU FW 1.1.2.65. Model: llama3.2:1b.
We found this by running OpenFlowLM-Next's server-api conformance suite (specs/server-api/tests/, commit eb65600) against flm serve. Related but different trigger: #498.
- Ngôn ngữ chính
- C++
- Star
- 2.1k
- Fork
- 184
- Merge trung bình
- 12 giờ 22 phút
- Pull request đã merge (30 ngày)
- 239
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của ROCm/FastFlowLM
-
Update Gemma tokenizer.json after Google's recent fixCó thể đã có người làm @four1er đã nhận 6 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
ROCm/FastFlowLM#1057 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
ROCm/FastFlowLM#757 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
No valid checkpoint to restore + Max length reached on multi-turn tool calls (Qwen3.6-MoE, NPU)Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
ROCm/FastFlowLM#744 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Truncated tool call is emitted as a complete one (unterminated heredoc reaches the client)Có thể đã có người làm @Javinator9889 đã nhận 72 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
ROCm/FastFlowLM#741 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Download timeoutCó thể đã có người làm @stdevPavelmc đã nhận 200 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
ROCm/FastFlowLM#520 · 7 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của ROCm/FastFlowLM
Issue tương tự
-
bug good first issue help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
difficulty:easy func:gui prio:normal type:bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
NatronGitHub/Natron#2118 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100
-
bug difficulty:easy prio:low
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
NatronGitHub/openfx-io#523 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
ArduPilot/ardupilot_gazebo#195 ·