Skip to content

Key.rs enum from SDK is missing multiple enum values which results in failing to read available keys with the SDK, especially the default key "Default Read-Only Admin API Key" #746

@akinsella

Description

@akinsella

Description
As of version 0.31.0 of the SDK (The most recent one to date), it is not possible to read Keys with the SDK since the Action enum Action::AllGet is missing along with multiple other enum values. Though, the enum value Action::AllGet ("*.get") is used by the default created Key "Default Read-Only Admin API Key" with the following code in Meilisearch:

    pub fn default_read_only_admin() -> Self {
        let now = OffsetDateTime::now_utc();
        let uid = Uuid::new_v4();
        Self {
            name: Some("Default Read-Only Admin API Key".to_string()),
            description: Some("Use it to read information across the whole database. Caution! Do not expose this key on a public frontend".to_string()),
            uid,
            actions: vec![Action::AllGet, Action::KeysGet],
            indexes: vec![IndexUidPattern::all()],
            expires_at: None,
            created_at: now,
            updated_at: now,
        }
    }

As a result, even without custom key creation, it is not possible to iterate on existing keys with the current version of the SDK.

Expected behavior
Should be able to read keys via the SDK API with the following code:

    pub async fn get_keys(&self, key_name: &str) -> Result<Vec<Key>, Error> {
        Ok(KeysQuery::new()
            .with_offset(0)
            .with_limit(1000)
            .execute(&self.meilisearch_client)
            .await
            .unwrap()
            .results
            .into_iter()
            .filter(|k| k.name.clone().unwrap() == key_name)
            .collect::<Vec<Key>>())
    }

Current behavior
thread 'tokio-runtime-worker' panicked at src/meilisearch/service.rs:94:14:
called Result::unwrap() on an Err value: ParseError(Error("unknown variant *.get, expected one of *, search, documents.add, documents.get, documents.delete, indexes.create, indexes.get, indexes.update, indexes.delete, tasks.get, settings.get, settings.update, stats.get, dumps.create, dumps.get, version, keys.get, keys.create, keys.update, keys.delete", line: 1, column: 1065))

Screenshots or Logs
If applicable, add screenshots or logs to help explain your problem.

Environment (please complete the following information):

  • OS: Any
  • Meilisearch version: v1.22.2
  • meilisearch-rust version: v0.31.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions