Skip to content

fix(batch): accept empty structured results - #2473

Closed
hsusul wants to merge 1 commit into
567-labs:mainfrom
hsusul:fix/batch-empty-result
Closed

fix(batch): accept empty structured results#2473
hsusul wants to merge 1 commit into
567-labs:mainfrom
hsusul:fix/batch-empty-result

Conversation

@hsusul

@hsusul hsusul commented Jul 20, 2026

Copy link
Copy Markdown

Summary

Allow valid empty structured objects in batch results to reach Pydantic validation.

Problem

BatchProcessor.parse_results() treats an extracted {} response as an
extraction failure. Models whose fields have defaults therefore receive a
BatchError instead of a successfully validated result.

This affects both OpenAI JSON-schema batch responses and Anthropic tool-use
batch responses.

Root cause

The parser used a truthiness check for extracted_data, conflating an empty
dictionary with the None sentinel returned when no structured result could
be extracted.

Fix

Check explicitly for None. Empty dictionaries are now validated normally,
while absent and malformed results retain the existing error behavior.

Test plan

  • Added a regression covering an OpenAI batch response containing {}
  • Added the equivalent Anthropic tool-use response
  • Verified both fail before the fix and pass afterward
  • Ran the focused batch suite, broad offline suite, Ruff, ty, and pre-commit

Compatibility considerations

This is backwards-compatible. Only valid empty mappings change behavior;
missing or malformed results continue to produce BatchError.

Issue ticket number and link

N/A — independently discovered; no matching issue found

@jxnl

jxnl commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

Consolidated and shipped in #2495. Closing this focused patch as superseded; thank you for the contribution.

@jxnl jxnl closed this Jul 29, 2026
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.

2 participants