Skip to content

fix(pixel-inference): validate presence_penalty and frequency_penalty float bounds - #5941

Closed
vaibhavsrv wants to merge 1 commit into
Osmantic:public-betafrom
vaibhavsrv:fix/pixel-inference-penalties
Closed

vaibhavsrv wants to merge 1 commit into
Osmantic:public-betafrom
vaibhavsrv:fix/pixel-inference-penalties

Conversation

@vaibhavsrv

Copy link
Copy Markdown
Contributor

Why this matters

In ods/extensions/services/pixel-inference/app/main.py, _prepare(payload, grant) admits presence_penalty and frequency_penalty directly without verifying that they conform to the canonical [-2.0, 2.0] floating point boundaries specified by the OpenAI completions protocol. When a request supplies an out-of-range value (e.g. 5.0 or -10.0) or non-numeric/boolean parameters (e.g. true or string descriptions), the invalid argument is forwarded to the backend inference runtime, causing model server crashes, unexpected sampling failure, or unhandled 500 errors.

This change adds a targeted loop validating both presence_penalty and frequency_penalty in _prepare. If either parameter is present, it verifies that its type is int or float (excluding bool) and that its value falls within [-2.0, 2.0], raising ShareError(400, f'invalid_{penalty}') on violation. All existing valid penalty values and omissions continue to behave identically.

Validation

  • Tested baseline reproduction against unpatched code: passing {"presence_penalty": 5.0} or {"frequency_penalty": True} bypassed checks and was admitted into the prepared payload.
  • Tested post-fix behavior: out-of-range penalties ($<-2.0$ or $>2.0$) and non-numeric types are rejected with HTTP 400 and code invalid_presence_penalty / invalid_frequency_penalty; valid values in [-2.0, 2.0] pass unmodified.
  • Telemetry statement: "Pixel-inference suites: 3 passed. New-test Ruff, py_compile, and diff checks pass; new regression wired into Linux CI."

Overlap check

Risk / AI disclosure

AI-assisted investigation, implementation, and regression verification. This strengthens request boundary validation and does not alter runtime execution or running containers. Independent human review and qualification remain gates.

Follow-up integration evidence

Composed cleanly on top of #5569, #5871, and #5875 at HEAD without conflicts. Production and test diffs passed together; adjacent pixel-agent and pixel-settings checks remain intact.
Backlog composition was local-only (production/test diffs, excluding workflow/Makefile wiring); it is not an upstream merge or independent human approval. Declared live-review gates remain open.

@Lightheartdevs

Copy link
Copy Markdown
Collaborator

Thanks for this contribution. public-beta was promoted into main on 2026-09-24 and no longer receives changes, so we're closing pull requests that target it. This isn't a judgment on the change itself. If it's still needed, please rebase onto main and open a focused PR. See #7253 for details and the contribution policy.

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.

2 participants