Handling correctly negative values in /v3/tokenize endpoint#4324
Open
przepeck wants to merge 2 commits into
Open
Handling correctly negative values in /v3/tokenize endpoint#4324przepeck wants to merge 2 commits into
przepeck wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the /v3/tokenize request parsing so that negative values for the max_length parameter are rejected (avoiding the previous signed-to-size_t conversion behavior) and adds coverage for this case.
Changes:
- Parse
max_lengthonly as an unsigned integer and update the associated validation error string. - Update existing unit test expectations for the new error message.
- Add a unit test that verifies negative
max_lengthis rejected.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/tokenize/tokenize_parser.cpp |
Tightens max_length validation to unsigned-only and updates the error message. |
src/test/tokenize_parser_test.cpp |
Updates the expected error message and adds a negative-max_length test case. |
Comment on lines
+84
to
88
| if (it->value.IsUint()) { | ||
| size_t max_length = it->value.GetUint(); | ||
| request.parameters["max_length"] = max_length; | ||
| // Keep OVMS tokenize API contract: max_length implies truncation. | ||
| request.parameters["truncation"] = true; |
mzegla
approved these changes
Jun 25, 2026
dtrawins
reviewed
Jun 25, 2026
| if (it != parsedJson.MemberEnd()) { | ||
| if (it->value.IsInt()) { | ||
| size_t max_length = it->value.GetInt(); | ||
| if (it->value.IsUint()) { |
Collaborator
Author
There was a problem hiding this comment.
yes, I will add additional condition for 0
dtrawins
approved these changes
Jun 26, 2026
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.
🛠 Summary
CVS-189517
Changing handling of negative values of max_length parameter.
🧪 Checklist
``