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

[BUG] validation error for Location #72

Open
ajkessel opened this issue Jul 8, 2024 · 1 comment
Open

[BUG] validation error for Location #72

ajkessel opened this issue Jul 8, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@ajkessel
Copy link

ajkessel commented Jul 8, 2024

This is with the latest git code, as well as 0.0.2 and 0.0.3 releases, trying to retrieve an album. Seems not to be a problem with 0.0.1.

[ERROR@aiograpi] 1 validation error for Location
external_id
  Input should be a valid integer, unable to parse string as an integer [type=int_parsing, input_value='None', input_type=str]
    For further information visit https://errors.pydantic.dev/2.8/v/int_parsing
Traceback (most recent call last):
  File "/path/lib/python3.10/site-packages/aiograpi/mixins/media.py", line 256, in media_info
    media = await self.media_info_gql(media_pk)
  File "/path/lib/python3.10/site-packages/aiograpi/mixins/media.py", line 210, in media_info_gql
    extract_location(data["shortcode_media"]["location"])
  File "/path/lib/python3.10/site-packages/aiograpi/extractors.py", line 305, in extract_location
    return Location(**data)
  File "/path/lib/python3.10/site-packages/pydantic/main.py", line 193, in __init__
    self.__pydantic_validator__.validate_python(data, self_instance=self)
pydantic_core._pydantic_core.ValidationError: 1 validation error for Location
external_id
  Input should be a valid integer, unable to parse string as an integer [type=int_parsing, input_value='None', input_type=str]
    For further information visit https://errors.pydantic.dev/2.8/v/int_parsing
@ajkessel ajkessel added the bug Something isn't working label Jul 8, 2024
@ajkessel
Copy link
Author

ajkessel commented Jul 8, 2024

Seems like the issue here is external_id is expected to be an int, so this is one to fix it:

--- orig/aiograpi/extractors.py 2024-07-08 11:35:29.094408582 -0700
+++ fixed/aiograpi/extractors.py  2024-07-08 10:43:51.016256124 -0700
@@ -288,7 +288,7 @@
     if not data:
         return None
     data["pk"] = data.get("id", data.get("pk", data.get("location_id", None)))
-    data["external_id"] = str(data.get("external_id", data.get("facebook_places_id")))
+    data["external_id"] = int(data.get("external_id", data.get("facebook_places_id")))
     data["external_id_source"] = data.get(
         "external_id_source", data.get("external_source")
     )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant