Skip to content

fix(file source): avoid warning for empty files too small to fingerprint - #25897

Open
an-cor wants to merge 2 commits into
vectordotdev:masterfrom
an-cor:fix-small-empty-file-warning
Open

fix(file source): avoid warning for empty files too small to fingerprint#25897
an-cor wants to merge 2 commits into
vectordotdev:masterfrom
an-cor:fix-small-empty-file-warning

Conversation

@an-cor

@an-cor an-cor commented Jul 20, 2026

Copy link
Copy Markdown

Summary

This PR fixes #1065 by avoiding the Currently ignoring file too small to fingerprint warning for empty files.

The existing behavior emits the same warning for empty files and for non-empty files that are too small to fingerprint. Empty files can be common in production logging environments, especially with short-lived jobs or pods, so warning on them can create noisy logs without giving users actionable information.

This change keeps the existing warning behavior for non-empty files that are too small to fingerprint, but skips the warning for empty files.

Vector configuration

No full Vector configuration was used for this change. The behavior is covered at the file-source-common fingerprinter level with a targeted unit test.

How did you test this PR?

Tested locally on macOS with targeted file-source-common tests.

Commands run:

cargo test -p file-source-common no_error_on_empty_file
cargo test -p file-source-common fingerprinter
cargo fmt --check
git diff --check

Results:

  • no_error_on_empty_file passed
  • fingerprinter test filter passed: 8 passed, 0 failed
  • cargo fmt --check passed
  • git diff --check passed

Change Type

  • Bug fix
  • New feature
  • Dependencies
  • Non-functional (chore, refactoring, docs)
  • Performance

Is this a breaking change?

  • Yes
  • No

Does this PR include user facing changes?

References

Notes

This PR includes a changelog fragment:

changelog.d/1065-empty-file-fingerprint-warning.fix.md

Signed-off-by: Angel Coronel <angelcoronel15@gmail.com>
@an-cor
an-cor requested a review from a team as a code owner July 20, 2026 05:58
@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@datadog-vectordotdev

This comment has been minimized.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e8f82d1f3a

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

match error.kind() {
ErrorKind::UnexpectedEof => {
if !known_small_files.contains_key(path) {
if file_size != Some(0) && !known_small_files.contains_key(path) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep remove_after tracking for empty files

When the file source uses checksum fingerprinting with remove_after_secs, this branch now suppresses both the warning and the insertion into known_small_files for zero-byte files. The cleanup path deletes only entries from known_small_files after the grace period (lib/file-source/src/file_server.rs cleanup loop), so an empty matched file is no longer removed even though it is already at EOF and previously was tracked for removal. Suppress emit_file_checksum_failed separately while still recording the path for remove_after_secs cleanup.

Useful? React with 👍 / 👎.

@an-cor

an-cor commented Jul 26, 2026

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

@an-cor an-cor changed the title Avoid warning for empty files too small to fingerprint fix(file source): avoid warning for empty files too small to fingerprint Jul 26, 2026
Signed-off-by: Angel Coronel <angelcoronel15@gmail.com>
@an-cor

an-cor commented Jul 26, 2026

Copy link
Copy Markdown
Author

Thanks for the review. I updated the implementation so empty files are still inserted into known_small_files for retry/cleanup bookkeeping, while only suppressing emit_file_checksum_failed for empty files. I also updated the regression test to verify that empty files remain tracked and non-empty small files still emit the checksum warning.

@an-cor

an-cor commented Jul 26, 2026

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4a67d8d131

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +228 to +229
if file_size != Some(0) {
emitter.emit_file_checksum_failed(path);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Warn when an initially empty file gains partial content

When a matched file is first scanned while empty, this branch suppresses the warning but still inserts its path into known_small_files. If the file later gains non-empty content without enough newlines to fingerprint, subsequent discovery scans skip this entire block because the path is already present, so the warning that this change intends to preserve for non-empty undersized files is never emitted. Track whether a warning was emitted separately from the removal-tracking map, or allow the first non-empty failure to emit it.

Useful? React with 👍 / 👎.

let metadata = match fs::metadata(path).await {
Ok(metadata) => {
if !metadata.is_dir() {
file_size = Some(metadata.len());

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Treat empty compressed streams as empty

For a valid gzip file whose decompressed stream is empty, metadata.len() is nonzero because it measures the compressed container, while fingerprint reads the decompressed stream and returns UnexpectedEof. The new check therefore still emits emit_file_checksum_failed for this supported form of empty input, contrary to the changelog's empty-file behavior. Determine emptiness from the stream being fingerprinted rather than the on-disk compressed size.

Useful? React with 👍 / 👎.

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.

Only warn about small files when they are not empty

1 participant