Skip to content

[9.4](backport #52077) Fix silent event drop when a parser clears message content#52197

Open
mergify[bot] wants to merge 1 commit into
9.4from
mergify/bp/9.4/pr-52077
Open

[9.4](backport #52077) Fix silent event drop when a parser clears message content#52197
mergify[bot] wants to merge 1 commit into
9.4from
mergify/bp/9.4/pr-52077

Conversation

@mergify

@mergify mergify Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Proposed commit message

Fix silent event drop when a parser clears message content

A parser can move the decoded data into the event fields and clear the
content, for example an ndjson parser configured without a message_key. When
such an object was read through the readFile path (any content-type other than
application/json or application/x-ndjson), the input dropped every event with
no error logged, because it only published when the message content was
non-empty. Events are now published when either the content or the fields are
populated.

The bug was first seen in as SDH affecting a customer.

The aws-s3 input picks a read path based on each object's Content-Type. Objects served as application/json and application/x-ndjson go through a JSON reader that ignores the configured parsers, so the missing message_key never mattered. Any other content-type routes the object through the generic file-reader path, which does run the ndjson parser.

Stage 1: the parser doesn't drop anything. With no message_key, the parser returns empty content plus the parsed JSON, and writes those parsed keys into the event's fields:

decode() returns empty content when no message_key
the parsed JSON is written into the event fields
So at this point the data is fully intact. It's in message.Fields, only message.Content has been cleared.

Stage 2: the event is dropped here. In the S3 file-reader loop, there is a guard that only checks whether message.Content is non-empty. Since the parser emptied Content, the whole block is skipped, eventCallback is never called, and the fields that hold the data are discarded with no log line:

readFile only emits when len(message.Content) > 0

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works. Where relevant, I have used the stresstest.sh script to run them under stress conditions and race detector to verify their stability.
  • I have added an entry in ./changelog/fragments using the changelog tool.

Disruptive User Impact

No. They actually fix a bug!

How to test this PR locally

This reproduces the customer's case: an integration policy with an ndjson
parser and no message_key, reading S3 objects whose Content-Type is not
application/json / application/x-ndjson (e.g. text/plain).
Before the fix no events are ingested and nothing is logged while after the fix the events are ingested with the JSON
decoded into their fields.

Related issues

Use cases

Screenshots

Logs


This is an automatic backport of pull request #52077 done by [Mergify](https://mergify.com).

* Fix silent event drop when a parser clears message content

* Update 1784536512-fix-awss3-readfile-drops-parser-fields.yaml

* linter fixes

* linter fixes

(cherry picked from commit 786fbdc)
@mergify mergify Bot added the backport label Jul 22, 2026
@mergify
mergify Bot requested a review from a team as a code owner July 22, 2026 12:50
@mergify mergify Bot added the backport label Jul 22, 2026
@botelastic botelastic Bot added the needs_team Indicates that the issue/PR needs a Team:* label label Jul 22, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🤖 GitHub comments

Just comment with:

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

@github-actions github-actions Bot added Team:obs-ds-hosted-services Label for the Observability Hosted Services team bugfix labels Jul 22, 2026
@botelastic botelastic Bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Jul 22, 2026
@infra-vault-gh-plugin-prod

Copy link
Copy Markdown

Pinging @elastic/obs-ds-hosted-services (Team:obs-ds-hosted-services)

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

Labels

backport bugfix Team:obs-ds-hosted-services Label for the Observability Hosted Services team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant