Detect input/output blocks with any whitespace before the brace#19268
Open
lucabelluccini wants to merge 1 commit into
Open
Detect input/output blocks with any whitespace before the brace#19268lucabelluccini wants to merge 1 commit into
lucabelluccini wants to merge 1 commit into
Conversation
The INPUT_BLOCK_RE / OUTPUT_BLOCK_RE regexes in ConfigStringLoader only
matched zero-or-more literal spaces between the `input`/`output` keyword
and the opening `{`. A config that put the brace on a new line (or used
tabs), e.g.
output
{
file { ... }
}
was not detected, so Logstash silently injected a default stdin input
and/or stdout output. Switch the ` *` matcher to `\s*` so newlines and
tabs are honored too.
Also emit a warning when a default input or output is injected, including
the pipeline id so the source pipeline can be identified.
Fixes elastic#19266
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
🤖 GitHub commentsJust comment with:
|
Contributor
|
This pull request does not have a backport label. Could you fix it @lucabelluccini? 🙏
|
Contributor
Author
💛 Build succeeded, but was flaky
Failed CI Steps |
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
ConfigStringLoaderdecides whether to inject a defaultstdininput and/orstdoutoutput by matching theinput/outputkeyword immediately followed by{. The regexes only allowed zero-or-more literal spaces between the keyword and the brace:So a perfectly valid config that puts the opening brace on a new line (or uses tabs) was not detected, and Logstash silently added a default output out of nowhere:
This switches the
*matcher to\s*, so newlines and tabs between the keyword and{are honored.Additional change
When a default input or output is injected, a
warnis now logged (including thepipeline_id) so users are told a default was added and can identify which pipeline it happened on. Previously the injection was completely silent.Tests
Added specs to
local_spec.rbcovering:{by a newline, tab, mixed whitespace, and no whitespaceAll
local_spec.rbexamples pass (47 examples, 0 failures).Fixes #19266
🤖 Generated with Claude Code