Skip to content

fix: show correct available keys in empty-text warning - #515

Open
Sanjays2402 wants to merge 2 commits into
huggingface:mainfrom
Sanjays2402:fix/empty-text-warning-keys
Open

Sanjays2402 wants to merge 2 commits into
huggingface:mainfrom
Sanjays2402:fix/empty-text-warning-keys

Conversation

@Sanjays2402

@Sanjays2402 Sanjays2402 commented Aug 27, 2026 •

Copy link
Copy Markdown

Summary

The warning logged when get_document_from_dict finds a document without text was showing data.keys() — but the default adapter already popped keys into parsed_data["text"] and parsed_data["metadata"], so by the time the warning fires the raw dict is empty. A user sees Available keys: [] and has no idea if their text_key is wrong or the field just has an empty value.

Fix

Snapshot original_keys before the adapter runs, then:

  • If text_key was not found — show the real available keys
  • If text_key was found but the value is empty — say so explicitly

Closes #341.


Note

Low Risk
Logging-only change in the reader skip path; document filtering behavior is unchanged aside from clearer diagnostics.

Overview
Fixes misleading “Available keys: []” logs when BaseReader.get_document_from_dict skips a document with no text.

The default adapter mutates the raw record (pops text_key, metadata, etc.) before the warning runs, so the old message used post-adapter data.keys(). The change captures original_keys before calling the adapter, then branches the one-time warning: if text_key was missing, it lists those keys; if text_key was present but empty, it says the value was empty instead of implying a wrong key name.

Reviewed by Cursor Bugbot for commit 0eb3dd8. Bugbot is set up for automated code reviews on this repo. Configure here.

Sanjays2402 and others added 2 commits August 27, 2026 00:25
The warning logged when a document has no text field was showing
data.keys() - but the default adapter pops the text_key into
parsed_data.text and all remaining keys into parsed_data.metadata,
so by the time the warning fires data is already empty.

Fix: snapshot the original keys before the adapter runs, then show
the real available keys if text_key was not found, or clarify that
the key was found but its value was empty.

Closes huggingface#341.
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.

invalid warning message

2 participants