Skip to content

fix(agent): propagate file upload read errors - #754

Open
felix-windsor wants to merge 1 commit into
bytedance:mainfrom
felix-windsor:fix/upload-read-error
Open

fix(agent): propagate file upload read errors#754
felix-windsor wants to merge 1 commit into
bytedance:mainfrom
felix-windsor:fix/upload-read-error

Conversation

@felix-windsor

Copy link
Copy Markdown

Summary

  • propagate non-EOF errors returned by io.ReadFull during file uploads
  • preserve the existing EOF and final-partial-chunk behavior
  • add focused tests for full, partial, empty, and failed reads

Problem

The upload loop stores the result of io.ReadFull in rerr, but checks the unrelated outer err variable. A disk or network-filesystem read error is therefore ignored, and the loop may send an incomplete chunk as if the read succeeded.

The helper introduced here classifies successful/full reads, normal completion (io.EOF and io.ErrUnexpectedEOF), and actual read failures explicitly. The caller returns before client.Send when a real read failure occurs.

Validation

  • go test ./transport/file_ext.go ./transport/file_ext_test.go
  • GOOS=linux GOARCH=amd64 go test -c -o /tmp/elkeid-transport.test ./transport
  • GOOS=linux GOARCH=amd64 go vet ./transport
  • go vet ./transport/file_ext.go ./transport/file_ext_test.go

The package-wide test executable is cross-compiled because the agent only provides plugin.Load and Plugin.Shutdown implementations for Linux.

Fixes #748

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.

Bug: agent 文件上传错误检查使用了错误的变量 (err 而非 rerr)

1 participant