Repository navigation
fix: show correct available keys in empty-text warning - #515
Open
Sanjays2402 wants to merge 2 commits into
Open
Sanjays2402 wants to merge 2 commits into
Sanjays2402 wants to merge 2 commits into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The warning logged when
get_document_from_dictfinds a document without text was showingdata.keys()— but the default adapter already popped keys intoparsed_data["text"]andparsed_data["metadata"], so by the time the warning fires the raw dict is empty. A user seesAvailable keys: []and has no idea if theirtext_keyis wrong or the field just has an empty value.Fix
Snapshot
original_keysbefore the adapter runs, then:text_keywas not found — show the real available keystext_keywas found but the value is empty — say so explicitlyCloses #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_dictskips 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-adapterdata.keys(). The change capturesoriginal_keysbefore calling the adapter, then branches the one-time warning: iftext_keywas missing, it lists those keys; iftext_keywas 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.