Repository: meilisearch/meilisearch
File: crates/meilisearch/tests/documents/get_documents.rs (Rust)

Code before:
    "###);
}

#[actix_rt::test]
async fn get_document_invalid_ids() {
    let server = Server::new_shared();
    let index = server.unique_index();
    let (task, _code) = index
        .add_documents(
            json!([
                { "id": 0, "color": "red" },
                { "id": 1, "color": "blue" },
                { "id": 2, "color": "blue" },
                { "id": 3 },
            ]),
            Some("id"),
        )
        .await;
    index.wait_task(task.uid()).await.succeeded();

    let (response, code) = index.fetch_documents(json!({"ids": ["0", "illegal/docid"] })).await;
    let (response2, code2) = index.get_all_documents_raw("?ids=0,illegal/docid").await;
    snapshot!(code, @"400 Bad Request");
    snapshot!(json_string!(response, { ".enqueuedAt" => "[date]" }), @r###"
    {
      "message": "In `.ids[1]`:Document identifier `\"illegal/docid\"` is invalid. A document identifier can be of type integer or string, only composed of alphanumeric characters (a-z A-Z 0-9), hyphens (-) and underscores (_), and can not be more than 511 bytes.",
      "code": "invalid_document_ids",
      "type": "invalid_request",
      "link": "https://docs.meilisearch.com/errors#invalid_document_ids"
    }
    "###);
    assert_eq!(code, code2);
    assert_eq!(response, response2);
}

#[actix_rt::test]
async fn get_document_not_found_ids() {
    let server = Server::new_shared();
    let index = server.unique_index();
    let (task, _code) = index
        .add_documents(
            json!([
                { "id": 0, "color": "red" },
                { "id": 1, "color": "blue" },
                { "id": 2, "color": "blue" },
                { "id": 3 },
            ]),
            Some("id"),
        )
        .await;
    index.wait_task(task.uid()).await.succeeded();

Review comment (suggestion):
```suggestion
      "message": "In `.ids[1]`: Document identifier `\"illegal/docid\"` is invalid. A document identifier can be of type integer or string, only composed of alphanumeric characters (a-z A-Z 0-9), hyphens (-) and underscores (_), and can not be more than 511 bytes.",
```

Nice error message, but we should put a space here 😁 

Code after:
    "###);
}

#[actix_rt::test]
async fn get_document_invalid_ids() {
    let server = Server::new_shared();
    let index = server.unique_index();
    let (task, _code) = index
        .add_documents(
            json!([
                { "id": 0, "color": "red" },
                { "id": 1, "color": "blue" },
                { "id": 2, "color": "blue" },
                { "id": 3 },
            ]),
            Some("id"),
        )
        .await;
    index.wait_task(task.uid()).await.succeeded();

    let (response, code) = index.fetch_documents(json!({"ids": ["0", "illegal/docid"] })).await;
    let (response2, code2) = index.get_all_documents_raw("?ids=0,illegal/docid").await;
    snapshot!(code, @"400 Bad Request");
    snapshot!(json_string!(response, { ".enqueuedAt" => "[date]" }), @r###"
    {
      "message": "In `.ids[1]`: Document identifier `\"illegal/docid\"` is invalid. A document identifier can be of type integer or string, only composed of alphanumeric characters (a-z A-Z 0-9), hyphens (-) and underscores (_), and can not be more than 511 bytes.",
      "code": "invalid_document_ids",
      "type": "invalid_request",
      "link": "https://docs.meilisearch.com/errors#invalid_document_ids"
    }
    "###);
    assert_eq!(code, code2);
    assert_eq!(response, response2);
}

#[actix_rt::test]
async fn get_document_not_found_ids() {
    let server = Server::new_shared();
    let index = server.unique_index();
    let (task, _code) = index
        .add_documents(
            json!([
                { "id": 0, "color": "red" },
                { "id": 1, "color": "blue" },
                { "id": 2, "color": "blue" },
                { "id": 3 },
            ]),
            Some("id"),
        )
        .await;
    index.wait_task(task.uid()).await.succeeded();