Unify payload size threshold validation across TOML and stdin config paths#7045
Merged
Conversation
6 tasks
Copilot
AI
changed the title
[WIP] Fix duplicate validation inconsistency for payloadSizeThreshold
Unify payload size threshold validation across TOML and stdin config paths
Jun 5, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR consolidates validation for the gateway.payload_size_threshold (TOML) and gateway.payloadSizeThreshold (stdin JSON) configuration fields so both surfaces consistently reject explicitly configured non-positive values while preserving defaulting behavior when the field is omitted.
Changes:
- Introduces a shared
rules.PositiveIntegervalidator and uses it for stdin gateway config validation. - Moves TOML
payload_size_thresholdvalidation to occur before defaults are applied, using TOML metadata to distinguish omitted vs explicitly-set values. - Extends/updates tests to cover invalid
payload_size_thresholdvalues and the new shared rule.
Show a summary per file
| File | Description |
|---|---|
| internal/config/validation.go | Switches stdin payloadSizeThreshold validation to the shared positive-integer rule. |
| internal/config/rules/rules.go | Adds PositiveInteger validator used across config validation paths. |
| internal/config/rules/rules_test.go | Adds unit tests for the new PositiveInteger validator. |
| internal/config/config_core.go | Validates TOML payload_size_threshold before defaults (only when explicitly defined). |
| internal/config/config_core_test.go | Updates TOML tests to reject both 0 and negative payload_size_threshold values. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 5/5 changed files
- Comments generated: 1
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.
gateway.payload_size_threshold(TOML) andgateway.payloadSizeThreshold(stdin JSON) were validated in two places with different bounds, so0was accepted in TOML but rejected in stdin. This change consolidates the rule and makes both config surfaces reject explicit non-positive values consistently.What changed
rules.PositiveIntegervalidator for config fields that must be>= 1.payloadSizeThreshold/payload_size_thresholdchecks in both validation paths with the shared rule.0on the TOML path.TOML path
gateway.payload_size_thresholdbefore defaults are applied.0, so:0now fails validation instead of being silently normalizedstdin / JSON path
gateway.payloadSizeThreshold.Tests
0and negative values.