Skip to content

List object crashes fix#2011

Merged
jxnl merged 6 commits intomainfrom
cursor/567-267-list-object-crashes-fix-931e
Jan 16, 2026
Merged

List object crashes fix#2011
jxnl merged 6 commits intomainfrom
cursor/567-267-list-object-crashes-fix-931e

Conversation

@jxnl
Copy link
Copy Markdown
Collaborator

@jxnl jxnl commented Jan 16, 2026

fix: prevent AttributeError for List[T] batch extractions and harden vertexai import

Describe your changes

This PR resolves the AttributeError: 'list' object has no attribute 'rawresponse' that occurred during batch extractions when response_model was List[T].

The fix involves:

  1. Introducing ListResponse, a list subclass, to correctly carry the _raw_response when a list of objects is returned.
  2. Updating prepare_response_model to properly handle list[T] (similar to Iterable[T]), ensuring it's processed as an IterableModel.
  3. Hardening the optional vertexai imports to prevent import instructor from crashing if vertexai is present but misconfigured.

This re-implements the core intent of the original, unmerged PR #1870 with dedicated unit tests.

Issue ticket number and link

Linear: 567-267
GitHub: #1303
Related PR: #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-267

Open in Cursor Open in Web


Important

Fix AttributeError in batch extractions for List[T] by introducing ListResponse and harden vertexai imports.

  • Behavior:
    • Fix AttributeError in batch extractions when response_model is List[T] by introducing ListResponse class in response_list.py.
    • Update process_response() and process_response_async() in response.py to use ListResponse for IterableBase models.
    • Enhance prepare_response_model() in core.py to handle list[T] as IterableModel.
  • Imports:
    • Harden vertexai imports in __init__.py and providers/__init__.py to prevent crashes if misconfigured.
  • Tests:
    • Add test_list_response.py to verify ListResponse behavior and integration with process_response().
  • Documentation:
    • Update raw_response.md to document usage of ListResponse with create_with_completion().

This description was created by Ellipsis for 512229c. You can customize this summary. It will automatically update as commits are pushed.

@cursor
Copy link
Copy Markdown

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
Copy Markdown

cloudflare-workers-and-pages Bot commented Jan 16, 2026

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 512229c Commit Preview URL

Branch Preview URL
Jan 16 2026, 05:58 PM

@jxnl
Copy link
Copy Markdown
Collaborator Author

jxnl commented Jan 16, 2026

@cursoragent fix everything ci etc and update change logs

@cursor
Copy link
Copy Markdown

cursor Bot commented Jan 16, 2026

I fixed the CI failures and updated the changelog.

  • CI fixes

    • ty was failing on tests/test_list_response.py (argument type). I updated the test so it stays type-correct under ty-tests.toml.
    • Core tests were failing in IterableModel() when the element type is a union (list[int | str] / list[ModelA | ModelB]). I made IterableModel() generate a safe name for union types.
    • I also adjusted prepare_response_model() so:
      • list[int | str] stays a simple type (FizzBuzz test passes),
      • list[User] becomes an IterableModel (the crash fix still works).
  • Changelog

    • Added an Unreleased → Fixed entry for the create_with_completion() + list[T] crash (#1303) in CHANGELOG.md.
  • Status

    • Latest CI on the PR branch is green: Ruff ✅ / ty ✅ / Test ✅.

Open in Cursor Open in Web

- Fix ty-tests failure in new ListResponse test\n- Keep list[int|str] treated as simple type (fizzbuzz)\n- Avoid IterableModel name crash for union task types\n- Add changelog entry for #1303

Co-authored-by: jason <jason@jxnl.co>
@jxnl jxnl marked this pull request as ready for review January 16, 2026 18:00
@jxnl jxnl merged commit f8cd6d1 into main Jan 16, 2026
16 checks passed
@jxnl jxnl deleted the cursor/567-267-list-object-crashes-fix-931e branch January 16, 2026 18:01
Copy link
Copy Markdown
Contributor

@ellipsis-dev ellipsis-dev Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

Looks good to me! 👍

Reviewed everything up to 512229c in 1 minute and 47 seconds. Click for details.
  • Reviewed 372 lines of code in 10 files
  • Skipped 0 files when reviewing.
  • Skipped posting 5 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. instructor/__init__.py:114
  • Draft comment:
    Consider logging an informative warning or error in the except block for the vertexai import to aid in diagnosing misconfigured optional dependencies.
  • Reason this comment was not posted:
    Confidence changes required: 70% <= threshold 85% None
2. instructor/providers/__init__.py:65
  • Draft comment:
    Similarly, for the vertexai import in providers/init.py, consider logging the exception details rather than silently passing, to improve debuggability when the optional dependency is present but misconfigured.
  • Reason this comment was not posted:
    Confidence changes required: 70% <= threshold 85% None
3. instructor/utils/core.py:595
  • Draft comment:
    The 'prepare_response_model' function involves multiple nested conversions (handling simple types, TypedDicts, and Iterable models) which adds complexity. Consider refactoring parts of it into helper functions or adding more summary comments to improve readability and maintainability.
  • Reason this comment was not posted:
    Confidence changes required: 70% <= threshold 85% None
4. instructor/processing/response.py:251
  • Draft comment:
    Typo: The log message "Returning takes from IterableBase" likely should read "Returning tasks from IterableBase".
  • Reason this comment was not posted:
    Comment was on unchanged code.
5. instructor/processing/response.py:359
  • Draft comment:
    Typo detected: "Returning takes from IterableBase" appears to use "takes" instead of "tasks". Please update the log message to reflect the correct term.
  • Reason this comment was not posted:
    Comment was on unchanged code.

Workflow ID: wflow_uBh3wFGVAoEqKmz3

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

cursor Bot pushed a commit that referenced this pull request Jan 16, 2026
Update CHANGELOG for PRs #2000, #2002, #2005, #2007, and #2011.

Co-authored-by: jason <jason@jxnl.co>
@jxnl jxnl mentioned this pull request Jan 16, 2026
3 tasks
@Blacksuan19
Copy link
Copy Markdown

finally!!!

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