Backport(v1.19): Config: accept a bare scalar for an array option in YAML syntax (#5413) - #5433
Merged
Merged
Conversation
**Which issue(s) this PR fixes**: Fixes #5149 **What this PR does / why we need it**: In YAML config syntax, a single scalar value for an array option is rejected. For example `retryable_response_codes: 503` fails with `array required but got 503`, while the classic syntax `retryable_response_codes 503` works fine. The difference is that the classic path delivers the value as the String `"503"`, which `Config.array_value` already splits into `["503"]`, whereas YAML hands it over as a bare `Integer` that falls straight through to the "array required" check. This wraps a non-String, non-Array, non-Hash scalar into a one-element array so both config syntaxes behave the same way. The wrapped value then flows through the existing `value_type` coercion, so `retryable_response_codes: 503` becomes `[503]` just like `retryable_response_codes: [503]` does. A Hash still raises as before, so an accidental mapping under an array option is not silently accepted. I could not run the full suite locally (my Ruby is 2.6 and Fluentd needs 3.2), so I verified the logic by tracing the exact `array_value` path and reproducing it in isolation; CI should confirm. I added test cases in test/config/test_types.rb covering a bare integer with and without `value_type`, and that an existing array is left untouched. **Docs Changes**: None. **Release Note**: Fix a config error when a single scalar value is given to an array option in YAML config syntax (for example `retryable_response_codes: 503`). --------- Signed-off-by: Arpit Jain <arpitjain099@gmail.com> Signed-off-by: arpitjain099 <arpitjain099@gmail.com> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Watson1978
approved these changes
Jul 13, 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.
Which issue(s) this PR fixes:
Backport #5413
Fixes #5149
What this PR does / why we need it:
In YAML config syntax, a single scalar value for an array option is rejected. For example
retryable_response_codes: 503fails witharray required but got 503, while the classic syntaxretryable_response_codes 503works fine. The difference is that the classic path delivers the value as the String"503", whichConfig.array_valuealready splits into["503"], whereas YAML hands it over as a bareIntegerthat falls straight through to the "array required" check.This wraps a non-String, non-Array, non-Hash scalar into a one-element array so both config syntaxes behave the same way. The wrapped value then flows through the existing
value_typecoercion, soretryable_response_codes: 503becomes[503]just likeretryable_response_codes: [503]does. A Hash still raises as before, so an accidental mapping under an array option is not silently accepted.I could not run the full suite locally (my Ruby is 2.6 and Fluentd needs 3.2), so I verified the logic by tracing the exact
array_valuepath and reproducing it in isolation; CI should confirm. I added test cases in test/config/test_types.rb covering a bare integer with and withoutvalue_type, and that an existing array is left untouched.Docs Changes:
None.
Release Note:
Fix a config error when a single scalar value is given to an array option in YAML config syntax (for example
retryable_response_codes: 503).