Skip to content

Conversation

@jxnl
Copy link
Collaborator

@jxnl jxnl commented Jan 16, 2026

fix: Prevent AttributeError for List[Object] extractions

Describe your changes

This change resolves an AttributeError: 'list' object has no attribute 'rawresponse' that occurred when performing batch extractions (e.g., List[Object]). Previously, process_response would return a plain Python list for IterableBase and ParallelBase models, which could not store the _raw_response attribute expected by create_with_completion().

The fix introduces a new ListResponse class, a list subclass that can hold the _raw_response metadata. process_response and process_response_async are updated to return ListResponse for list-like outputs. Additionally, prepare_response_model now correctly handles List[T] and Iterable[T] (where T is a BaseModel) before simple type detection, ensuring they are properly wrapped as IterableModel.

Issue ticket number and link

Linear: 567-266
GitHub: instructor/issues/1303
Related PR: instructor/pull/1870

Checklist before requesting a review

  • I have performed a self-review of my code
  • If it is a core feature, I have added thorough tests.
  • If it is a core feature, I have added documentation.

Linear Issue: 567-266

Open in Cursor Open in Web

cursoragent and others added 3 commits January 16, 2026 17:26
Return a ListResponse wrapper for IterableBase and ParallelBase so create_with_completion can always access _raw_response when response_model is list-like (e.g., List[T]).

Co-authored-by: jason <[email protected]>
Adjust imports and typing to match project Ruff rules.

Co-authored-by: jason <[email protected]>
Add regression coverage that list-like response_model types are converted to IterableBase models.

Co-authored-by: jason <[email protected]>
@cursor
Copy link

cursor bot commented Jan 16, 2026

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@github-actions github-actions bot added bug Something isn't working python Pull requests that update python code size:M This PR changes 30-99 lines, ignoring generated files. labels Jan 16, 2026
@cloudflare-workers-and-pages
Copy link

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
instructor 86278f6 Commit Preview URL

Branch Preview URL
Jan 16 2026, 05:32 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working python Pull requests that update python code size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants