Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed crash due to DOI being a list #619

Merged
merged 1 commit into from
Oct 21, 2024
Merged

Conversation

jamesbraza
Copy link
Collaborator

I hit a new crash today:

    | Traceback (most recent call last):
    |   File "/path/to/.venv/lib/python3.12/site-packages/paperqa/agents/search.py", line 438, in process_file
    |     await tmp_docs.aadd(
    |   File "/path/to/.venv/lib/python3.12/site-packages/paperqa/docs.py", line 364, in aadd
    |     doc = await metadata_client.upgrade_doc_to_doc_details(
    |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |   File "/path/to/.venv/lib/python3.12/site-packages/paperqa/clients/__init__.py", line 207, in upgrade_doc_to_doc_details
    |     0 if not extra_fields else DocDetails(**extra_fields)
    |                                ^^^^^^^^^^^^^^^^^^^^^^^^^^
    |   File "/path/to/.venv/lib/python3.12/site-packages/pydantic/main.py", line 212, in __init__
    |     validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
    |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |   File "/path/to/.venv/lib/python3.12/site-packages/paperqa/types.py", line 567, in validate_all_fields
    |     data = cls.lowercase_doi_and_populate_doc_id(data)
    |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |   File "/path/to/.venv/lib/python3.12/site-packages/paperqa/types.py", line 390, in lowercase_doi_and_populate_doc_id
    |     if doi.startswith(url):
    |        ^^^^^^^^^^^^^^
    | AttributeError: 'list' object has no attribute 'startswith'
    +------------------------------------

Somehow it looks like the DocDetails input data for DOI was a list not a str (as expected).

This PR handles this new edge case

@jamesbraza jamesbraza added the bug Something isn't working label Oct 21, 2024
@jamesbraza jamesbraza self-assigned this Oct 21, 2024
@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Oct 21, 2024
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Oct 21, 2024
@jamesbraza jamesbraza merged commit 70e832f into main Oct 21, 2024
4 of 5 checks passed
@jamesbraza jamesbraza deleted the fixing-doi-edge-case branch October 21, 2024 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working lgtm This PR has been approved by a maintainer size:S This PR changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants