[PR #1663] [CLOSED] serve: a sampling field of the wrong type is a 400 that names it #3591

Closed
opened 2026-11-07 15:29:24 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/1663
Author: @midagedev
Created: 10/9/2026
Status: ❌ Closed

Base: main ← Head: request-sampling-types


📝 Commits (1)

  • c67db95 serve: a sampling field of the wrong type is a 400 that names it

📊 Changes

2 files changed (+63 additions, -1 deletions)

View changed files

📝 serve/server.py (+24 -0)
📝 serve/test_request_hardening.py (+39 -1)

📄 Description

Summary

A request with "temperature": "0.7", "top_k": 40.0 or "seed": true got a 200 and a greedy reply. The bad value replaced the configured default in run()'s merge, then sampling_keys dropped it as not a number. Now it is a 400 that names the field, as POST /settings and the run config already do.

What changed

  • serve/server.py: check_request_sampling(req) checks types only (a number for temperature, top_p, min_p and the penalties; an integer for top_k, penalty_last_n and seed; never bool). Chat, messages, count_tokens and responses call it before anything is sent.
  • serve/test_request_hardening.py: a wrong type gets 400 on each endpoint; in-type values of any range and null fields still get 200.

Ranges and every well-typed request behave as before.

Extra Notes

  • The 10 new refusal cases fail before the change (200 != 400). After it, test_request_hardening, test_server, test_frontend and test_responses pass (macOS, Python 3.14).
  • If you prefer, I can keep the configured default for a bad field and print a warning instead.
  • I used Claude Code to find this and draft the change. I ran the tests myself.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/1663 **Author:** [@midagedev](https://github.com/midagedev) **Created:** 10/9/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `request-sampling-types` --- ### 📝 Commits (1) - [`c67db95`](https://github.com/Niko1221/Strata/commit/c67db955745f7ce1c665a985d03415b096510e4d) serve: a sampling field of the wrong type is a 400 that names it ### 📊 Changes **2 files changed** (+63 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `serve/server.py` (+24 -0) 📝 `serve/test_request_hardening.py` (+39 -1) </details> ### 📄 Description ## Summary A request with `"temperature": "0.7"`, `"top_k": 40.0` or `"seed": true` got a 200 and a greedy reply. The bad value replaced the configured default in `run()`'s merge, then `sampling_keys` dropped it as not a number. Now it is a 400 that names the field, as POST /settings and the run config already do. ## What changed - `serve/server.py`: `check_request_sampling(req)` checks types only (a number for temperature, top_p, min_p and the penalties; an integer for top_k, penalty_last_n and seed; never bool). Chat, messages, count_tokens and responses call it before anything is sent. - `serve/test_request_hardening.py`: a wrong type gets 400 on each endpoint; in-type values of any range and null fields still get 200. Ranges and every well-typed request behave as before. ## Extra Notes - The 10 new refusal cases fail before the change (200 != 400). After it, test_request_hardening, test_server, test_frontend and test_responses pass (macOS, Python 3.14). - If you prefer, I can keep the configured default for a bad field and print a warning instead. - I used Claude Code to find this and draft the change. I ran the tests myself. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 15:29:24 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#3591
No description provided.