Skip to content

fix: convert str file path to Path before calling .stat() in _handle_file_or_url#165

Merged
dineshreddy91 merged 1 commit intomainfrom
devin/1773961955-fix-str-file-stat
Mar 19, 2026
Merged

fix: convert str file path to Path before calling .stat() in _handle_file_or_url#165
dineshreddy91 merged 1 commit intomainfrom
devin/1773961955-fix-str-file-stat

Conversation

@devin-ai-integration
Copy link
Copy Markdown
Contributor

Summary

Fixes AttributeError: 'str' object has no attribute 'stat' when passing a string file path to client.document.generate(file="some_file.pdf").

The _handle_file_or_url method accepts Union[Path, str] for the file parameter, but the branch that handles file paths with extensions called file.stat() without first converting the string to a Path object. Added file = Path(file) before the .stat() call — this is safe for both str and Path inputs since Path(Path(...)) is a no-op.

Review & Testing Checklist for Human

  • Verify fix by running client.document.generate(file="some_file.pdf", ...) with a string path — should no longer raise AttributeError
  • Confirm passing a Path object still works as before

Notes

  • The same Path(file) conversion was already done two lines below when calling self._client.files.upload(file=Path(file), ...), so this makes the code consistent.
  • ImagePredictions._handle_images_or_urls is not affected — it uses a different pattern with str(image).

Link to Devin session: https://app.devin.ai/sessions/691f8a989ec340a397e56a2e178b91d7
Requested by: @DylanSoftware

…file_or_url

Co-Authored-By: dylan <dylan@carysoftwaresolutions.com>
@devin-ai-integration
Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@dineshreddy91 dineshreddy91 merged commit 819e23e into main Mar 19, 2026
4 checks passed
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