MarshalX / atproto

The AT Protocol (🦋 Bluesky) SDK for Python 🐍
https://atproto.blue
MIT License
391 stars 42 forks source link

Can't retrieve user feed #78

Closed Vadimkin closed 1 year ago

Vadimkin commented 1 year ago

Hello!

I am not able to fetch some user profiles — looks like this issue happens on profiles where author defined language of "skeets". For example you can check it with "uavibes.bsky.social" profile.

def main():
    client = Client()
    client.login(...)

    profile_feed = client.bsky.feed.get_author_feed({'actor': 'uavibes.bsky.social'})
    for feed_view in profile_feed.feed:
        print('-', feed_view.post.record.text)
Traceback ``` Traceback (most recent call last): File "/Users/vadym/Projects/vadym/uavibes/venv/lib/python3.11/site-packages/atproto/xrpc_client/models/utils.py", line 101, in _get_or_create model(**model_data) TypeError: Main.__init__() got an unexpected keyword argument 'langs' Traceback (most recent call last): File "/Users/vadym/Projects/vadym/uavibes/main.py", line 14, in main() File "/Users/vadym/Projects/vadym/uavibes/main.py", line 8, in main profile_feed = client.bsky.feed.get_author_feed({'actor': 'uavibes.bsky.social'}) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/vadym/Projects/vadym/uavibes/venv/lib/python3.11/site-packages/atproto/xrpc_client/namespaces/sync_ns.py", line 249, in get_author_feed return get_response_model(response, models.AppBskyFeedGetAuthorFeed.Response) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/vadym/Projects/vadym/uavibes/venv/lib/python3.11/site-packages/atproto/xrpc_client/models/utils.py", line 132, in get_response_model return get_or_create_model(response.content, model) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/vadym/Projects/vadym/uavibes/venv/lib/python3.11/site-packages/atproto/xrpc_client/models/utils.py", line 119, in get_or_create_model model_instance = get_or_create(model_data, model) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/vadym/Projects/vadym/uavibes/venv/lib/python3.11/site-packages/atproto/xrpc_client/models/utils.py", line 78, in get_or_create raise e File "/Users/vadym/Projects/vadym/uavibes/venv/lib/python3.11/site-packages/atproto/xrpc_client/models/utils.py", line 75, in get_or_create return _get_or_create(model_data, model, strict=strict) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/vadym/Projects/vadym/uavibes/venv/lib/python3.11/site-packages/atproto/xrpc_client/models/utils.py", line 103, in _get_or_create return from_dict(model, model_data, config=_DACITE_CONFIG) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/vadym/Projects/vadym/uavibes/venv/lib/python3.11/site-packages/dacite/core.py", line 64, in from_dict value = _build_value(type_=field_type, data=field_data, config=config) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/vadym/Projects/vadym/uavibes/venv/lib/python3.11/site-packages/dacite/core.py", line 97, in _build_value data = _build_value_for_collection(collection=type_, data=data, config=config) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/vadym/Projects/vadym/uavibes/venv/lib/python3.11/site-packages/dacite/core.py", line 154, in _build_value_for_collection return data_type(_build_value(type_=item_type, data=item, config=config) for item in data) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/vadym/Projects/vadym/uavibes/venv/lib/python3.11/site-packages/dacite/core.py", line 154, in return data_type(_build_value(type_=item_type, data=item, config=config) for item in data) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/vadym/Projects/vadym/uavibes/venv/lib/python3.11/site-packages/dacite/core.py", line 99, in _build_value data = from_dict(data_class=type_, data=data, config=config) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/vadym/Projects/vadym/uavibes/venv/lib/python3.11/site-packages/dacite/core.py", line 64, in from_dict value = _build_value(type_=field_type, data=field_data, config=config) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/vadym/Projects/vadym/uavibes/venv/lib/python3.11/site-packages/dacite/core.py", line 99, in _build_value data = from_dict(data_class=type_, data=data, config=config) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/vadym/Projects/vadym/uavibes/venv/lib/python3.11/site-packages/dacite/core.py", line 64, in from_dict value = _build_value(type_=field_type, data=field_data, config=config) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/vadym/Projects/vadym/uavibes/venv/lib/python3.11/site-packages/dacite/core.py", line 91, in _build_value data = config.type_hooks[type_](data) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/vadym/Projects/vadym/uavibes/venv/lib/python3.11/site-packages/atproto/xrpc_client/models/utils.py", line 31, in _record_model_type_hook return get_or_create_model(data, RECORD_TYPE_TO_MODEL_CLASS[record_type]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/vadym/Projects/vadym/uavibes/venv/lib/python3.11/site-packages/atproto/xrpc_client/models/utils.py", line 119, in get_or_create_model model_instance = get_or_create(model_data, model) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/vadym/Projects/vadym/uavibes/venv/lib/python3.11/site-packages/atproto/xrpc_client/models/utils.py", line 78, in get_or_create raise e File "/Users/vadym/Projects/vadym/uavibes/venv/lib/python3.11/site-packages/atproto/xrpc_client/models/utils.py", line 75, in get_or_create return _get_or_create(model_data, model, strict=strict) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/vadym/Projects/vadym/uavibes/venv/lib/python3.11/site-packages/atproto/xrpc_client/models/utils.py", line 107, in _get_or_create raise UnexpectedFieldError(msg) from e atproto.exceptions.UnexpectedFieldError: Main.Main got an unexpected keyword argument 'langs' ```

When Main class is extended with langs: t.Optional[t.List[str]] = None field – it works fine. However, I can't find this langs field in atproto docs, so that's why I didn't create PR for this change yet.

MarshalX commented 1 year ago

Hello! Lexicons were updated. The new version of the schema contains the "langs" field. Please update version: pip install -U atproto. Fix version 0.0.16

Vadimkin commented 1 year ago

@MarshalX thank you very much for this rapid fix! 🙌