fix(pixel-inference): validate stop parameter type as string, array of strings, or null - #5942
Open
vaibhavsrv wants to merge 1 commit into
Open
vaibhavsrv wants to merge 1 commit into
vaibhavsrv wants to merge 1 commit into
Conversation
…f strings, or null
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why this matters
In
ods/extensions/services/pixel-inference/app/main.py,_prepare(payload, grant)listsstopin the permittedFIELDSset but does not enforce type validation on its value. The completions specification requiresstopto be eithernull, a string, or an array of strings (e.g.["\n", "END"]). When a client supplies a non-string scalar (such as integer123, booleanfalse, or dictionary mapping) or a list containing non-string elements, the payload passes through_prepareand causes downstream serializer failures or unhandled 500 exceptions in inference engines.This change adds explicit validation for the
stopargument in_prepare. It acceptsNone, strings, or lists of strings, while raisingShareError(400, 'invalid_stop')for any other scalar type or mixed-type list. Standard string and array stop words continue to operate without alteration.Validation
{"stop": 123}or{"stop": [True]}bypassed_preparewithout error.invalid_stop; valid strings and string arrays pass cleanly.Overlap check
temperatureparameter bounds inpixel-inference.presence_penaltyandfrequency_penaltybounds inpixel-inference.pixel_settings.pixel_edge.This PR addresses only the
stopparameter contract inpixel-inference/app/main.pyand does not conflict with adjacent PRs.Risk / AI disclosure
AI-assisted defect analysis, implementation, and test isolation. This restricts malformed request parameters at the API gateway layer and does not modify persistent storage, models, or container runtime states. Independent human review remains a gate.
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.