sugyan / atrium

Rust libraries for Bluesky's AT Protocol services.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`app.bsky.feed.getPosts` fails with more than a certain number of arguments `uris`

sugyan opened this issue · comments

Versions

  • atrium-api: 0.21.0
  • atrium-xrpc: 0.10.4
  • atrium-xrpc-client: 0.5.2

How to reproduce

use atrium_api::client::AtpServiceClient;
use atrium_api::types::string::AtIdentifier;
use atrium_xrpc_client::reqwest::ReqwestClient;
use itertools::Itertools;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = AtpServiceClient::new(ReqwestClient::new("https://api.bsky.app"));
    let uris = client
        .service
        .app
        .bsky
        .feed
        .get_author_feed(atrium_api::app::bsky::feed::get_author_feed::Parameters {
            actor: AtIdentifier::Handle("atproto.com".parse()?),
            cursor: None,
            filter: None,
            limit: 30.try_into().ok(),
        })
        .await?
        .feed
        .iter()
        .map(|post| post.post.uri.clone())
        .unique()
        .collect_vec();
    client
        .service
        .app
        .bsky
        .feed
        .get_posts(atrium_api::app::bsky::feed::get_posts::Parameters {
            uris: uris.into_iter().take(22).collect(),
        })
        .await?;
    Ok(())
}

Output:

Error: XrpcResponse(XrpcError { status: 400, error: Some(Undefined(ErrorResponseBody { error: Some("InvalidRequest"), message: Some("Error: uris/0 must be a valid at-uri") })) })

If .take(22) is less than 21, no error occurs.