diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index 7ac668e54e83..86ebe1b3fb71 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -108,6 +108,7 @@ https://github.com/elastic/beats/compare/v8.8.1\...main[Check the HEAD diff] - Fix request trace filename handling in http_endpoint input. {pull}39410[39410] - Upgrade github.com/hashicorp/go-retryablehttp to mitigate CVE-2024-6104 {pull}40036[40036] - 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 c36bd7858f96..7e9c7c071523 100644 --- a/x-pack/filebeat/input/awss3/s3_objects.go +++ b/x-pack/filebeat/input/awss3/s3_objects.go @@ -265,7 +265,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 {