Skip to content

FIX: Handle missing prompt keys gracefully in write_txt - #3378

Open
Manohar Paturi (ManoharPaturi) wants to merge 3 commits into
microsoft:mainfrom
ManoharPaturi:fix/write-txt-missing-keys
Open

Manohar Paturi (ManoharPaturi) wants to merge 3 commits into
microsoft:mainfrom
ManoharPaturi:fix/write-txt-missing-keys

Conversation

@ManoharPaturi

Copy link
Copy Markdown
Contributor

Description

Fixes #3377

The write_txt helper previously looked up ex["prompt"] directly when serializing prompt dictionaries. If an item in the examples list was an empty dictionary or lacked a prompt key, the call crashed with a KeyError. This change safely extracts prompt values with ex.get("prompt") and falls back to an empty string so that empty entries and dictionaries with alternative metadata fields serialize cleanly.

Tests and Documentation

Added unit tests in test_text_helper.py covering basic serialization, empty inputs, roundtrip parsing with read_txt, and handling rows with missing or None prompt values.

No documentation change needed, so I did not run JupyText.

This branch has not been deployed

No deployments
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: write_txt raises KeyError on missing prompt key or empty rows

1 participant