Skip to content

Detect input/output blocks with any whitespace before the brace#19268

Open
lucabelluccini wants to merge 1 commit into
elastic:mainfrom
lucabelluccini:fix/config-block-detection-whitespace
Open

Detect input/output blocks with any whitespace before the brace#19268
lucabelluccini wants to merge 1 commit into
elastic:mainfrom
lucabelluccini:fix/config-block-detection-whitespace

Conversation

@lucabelluccini

Copy link
Copy Markdown
Contributor

Summary

ConfigStringLoader decides whether to inject a default stdin input and/or stdout output by matching the input/output keyword immediately followed by {. The regexes only allowed zero-or-more literal spaces between the keyword and the brace:

INPUT_BLOCK_RE  = /input *{/
OUTPUT_BLOCK_RE = /output *{/

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:

output
{
  file { ... }
}

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 warn is now logged (including the pipeline_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.rb covering:

  • input/output blocks separated from { by a newline, tab, mixed whitespace, and no whitespace
  • the warning being emitted when defaults are injected
  • the pipeline id appearing in the warning

All local_spec.rb examples pass (47 examples, 0 failures).

Fixes #19266

🤖 Generated with Claude Code

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>
@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

🤖 GitHub comments

Just comment with:

  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)
  • run exhaustive tests : Run the exhaustive tests Buildkite pipeline.

@mergify

mergify Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

This pull request does not have a backport label. Could you fix it @lucabelluccini? 🙏
To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-8./d is the label to automatically backport to the 8./d branch. /d is the digit.
  • If no backport is necessary, please add the backport-skip label

@lucabelluccini

Copy link
Copy Markdown
Contributor Author

FYI @robbavey - wrt #19266

@infra-vault-gh-plugin-prod

Copy link
Copy Markdown

💛 Build succeeded, but was flaky

Failed CI Steps

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

When using ConfigStringLoader, a default stdout can be added out of nowhere

1 participant