diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index 9df9f16951ba..fffd4ed48314 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -198,6 +198,7 @@ otherwise no tag is added. {issue}42208[42208] {pull}42403[42403] - Fix entityanalytics activedirectory provider full sync use before initialization bug. {pull}42682[42682] - In the `http_endpoint` input, fix the check for a missing HMAC HTTP header. {pull}42756[42756] - Prevent computer details being returned for user queries by Activedirectory Entity Analytics provider. {issue}11818[11818] {pull}42796[42796] +- Handle unexpectedEOF error in aws-s3 input and enforce retrying using download failed error {pull}42420[42756] *Heartbeat* diff --git a/x-pack/filebeat/input/awss3/s3_objects.go b/x-pack/filebeat/input/awss3/s3_objects.go index 5887f24ebf0c..3bf54359e800 100644 --- a/x-pack/filebeat/input/awss3/s3_objects.go +++ b/x-pack/filebeat/input/awss3/s3_objects.go @@ -266,7 +266,12 @@ func (p *s3ObjectProcessor) addGzipDecoderIfNeeded(body io.Reader) (io.Reader, e } func (p *s3ObjectProcessor) readJSON(r io.Reader) error { - dec := json.NewDecoder(r) + var buf bytes.Buffer + if _, err := io.Copy(&buf, r); err != nil { + // If an error occurs during the download, handle it here + return fmt.Errorf("%w: %w", errS3DownloadFailed, err) + } + dec := json.NewDecoder(&buf) dec.UseNumber() for dec.More() && p.ctx.Err() == nil {