Skip to content

Commit 375f990

Browse files
fix: get-modules uses /v1/bdbs/{id} module_list instead of 404 endpoint (#900)
The /v1/bdbs/{id}/modules endpoint is not supported on all Redis Enterprise clusters, causing a 404. The module data is available on the database object itself as module_list. Fetches /v1/bdbs/{id} and extracts the module_list field instead. Fixes #896.
1 parent b762713 commit 375f990

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

crates/redisctl/src/commands/enterprise/database_impl.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,6 +1177,9 @@ pub async fn update_database_shards(
11771177
}
11781178

11791179
/// Get database modules
1180+
///
1181+
/// Fetches the database object and extracts `module_list`, since the
1182+
/// `/v1/bdbs/{id}/modules` endpoint is not supported on all clusters.
11801183
pub async fn get_database_modules(
11811184
conn_mgr: &ConnectionManager,
11821185
profile_name: Option<&str>,
@@ -1185,12 +1188,17 @@ pub async fn get_database_modules(
11851188
query: Option<&str>,
11861189
) -> CliResult<()> {
11871190
let client = conn_mgr.create_enterprise_client(profile_name).await?;
1188-
let response = client
1189-
.get_raw(&format!("/v1/bdbs/{}/modules", id))
1191+
let response: serde_json::Value = client
1192+
.get_raw(&format!("/v1/bdbs/{}", id))
11901193
.await
11911194
.map_err(RedisCtlError::from)?;
11921195

1193-
let data = handle_output(response, output_format, query)?;
1196+
let modules = response
1197+
.get("module_list")
1198+
.cloned()
1199+
.unwrap_or(serde_json::Value::Array(vec![]));
1200+
1201+
let data = handle_output(modules, output_format, query)?;
11941202
print_formatted_output(data, output_format)?;
11951203
Ok(())
11961204
}

0 commit comments

Comments
 (0)