Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed

- `ak admin storage-gc run` now always sends `dry_run` explicitly, so a live run posts `{"dry_run": false}` instead of an empty body. Companion to artifact-keeper#3619, which makes `dry_run` required on the storage-GC endpoint and rejects unknown fields (422)

## [1.2.0] - 2026-07-13

### Added
Expand Down
31 changes: 28 additions & 3 deletions src/commands/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3975,13 +3975,23 @@ async fn toggle_ci_oidc_mapping(

// ---- Storage GC and reports ----

/// Build the `POST /api/v1/admin/storage-gc` request body.
///
/// `dry_run` is always sent explicitly. The generated field is
/// `Option<bool>` with `skip_serializing_if = "Option::is_none"`, so a `None`
/// drops the key and posts `{}` — which the backend rejects with 422 once
/// artifact-keeper#3619 lands (`dry_run` required, unknown fields denied).
fn storage_gc_body(dry_run: bool) -> artifact_keeper_sdk::types::StorageGcRequest {
artifact_keeper_sdk::types::StorageGcRequest {
dry_run: Some(dry_run),
}
}

async fn run_storage_gc(dry_run: bool, global: &GlobalArgs) -> Result<()> {
let client = client_for(global)?;
let spinner = output::spinner("Running storage garbage collection...");

let body = artifact_keeper_sdk::types::StorageGcRequest {
dry_run: dry_run.then_some(true),
};
let body = storage_gc_body(dry_run);

let r = client
.run_storage_gc()
Expand Down Expand Up @@ -7204,6 +7214,21 @@ mod tests {
}
}

#[test]
fn storage_gc_body_always_sends_dry_run() {
// A live run must send `"dry_run": false`, not an empty body: the
// backend requires the field and rejects unknown ones
// (artifact-keeper#3619).
assert_eq!(
serde_json::to_value(storage_gc_body(false)).unwrap(),
json!({ "dry_run": false })
);
assert_eq!(
serde_json::to_value(storage_gc_body(true)).unwrap(),
json!({ "dry_run": true })
);
}

#[test]
fn parse_storage_gc_oci_report() {
let cli = parse(&["test", "storage-gc", "oci-report", "--grace-hours", "48"]);
Expand Down
Loading