From a2020eb8452138ba27af32d5c9d18488c2608d77 Mon Sep 17 00:00:00 2001 From: Matthias Tafelmeier Date: Thu, 19 Mar 2026 13:58:49 +0100 Subject: [PATCH 1/4] docs: update README for Rust migration and fix credentialType field --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6cd137c..c592bcd 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Godon CLI -A Nim-based CLI tool for controlling and managing the Godon optimizer breeders via the Godon Control API. +A Rust-based CLI tool for controlling and managing the Godon optimizer breeders via the Godon Control API. ## Features @@ -146,7 +146,7 @@ Create a YAML configuration file `credential.yaml`: ```yaml name: "production_ssh_key" -credential_type: "ssh_private_key" +credentialType: "ssh_private_key" description: "SSH key for production servers" content: | -----BEGIN RSA PRIVATE KEY----- From a0d13758d032b3449b0b1f3760e24877659e2cb3 Mon Sep 17 00:00:00 2001 From: Matthias Tafelmeier Date: Thu, 19 Mar 2026 14:11:49 +0100 Subject: [PATCH 2/4] fix: fail on unexpected response format in breeder update Validate that response contains 'id' field instead of silently defaulting to 'unknown' --- src/main.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main.rs b/src/main.rs index 27fbbeb..0ac82bf 100644 --- a/src/main.rs +++ b/src/main.rs @@ -266,13 +266,17 @@ async fn handle_breeder_command(client: &GodonClient, cmd: BreederCommands, outp let response = client.update_breeder_from_yaml(&content).await; if response.success { - if matches!(output, OutputFormat::Text) { - if let Some(ref data) = response.data { - let id = data.get("id").and_then(|v| v.as_str()).unwrap_or("unknown"); - println!("Breeder updated successfully: {}", id); + if let Some(data) = response.data { + match data.get("id").and_then(|v| v.as_str()) { + Some(id) => { + if matches!(output, OutputFormat::Text) { + println!("Breeder updated successfully: {}", id); + } else { + format_output(&data, output); + } + } + None => write_error("Unexpected response format: missing 'id' field"), } - } else if let Some(data) = response.data { - format_output(&data, output); } } else { write_error(response.error.as_deref().unwrap_or("Unknown error")); From 8933f5a2fed4b208b42a22db2112f5f0ac9c081b Mon Sep 17 00:00:00 2001 From: Matthias Tafelmeier Date: Thu, 19 Mar 2026 14:16:53 +0100 Subject: [PATCH 3/4] fix(ci): check breeder subcommands in correct help context --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 98fffdc..87135f9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -276,8 +276,8 @@ jobs: # Test help shows new commands echo "Testing: help shows stop/start commands" - $BINARY_PATH --help | grep -q "stop" && echo "✅ stop command documented" || echo "❌ stop command missing" - $BINARY_PATH --help | grep -q "start" && echo "✅ start command documented" || echo "❌ start command missing" + $BINARY_PATH breeder --help | grep -q "stop" && echo "✅ stop command documented" || echo "❌ stop command missing" + $BINARY_PATH breeder --help | grep -q "start" && echo "✅ start command documented" || echo "❌ start command missing" echo "Testing: breeder purge --help shows --force flag" $BINARY_PATH breeder purge --help | grep -q "force" && echo "✅ --force flag documented in purge" || echo "❌ --force flag missing from purge" From d1cbfd5f7622ffa4289197fc5ebf59d4fea98e1e Mon Sep 17 00:00:00 2001 From: Matthias Tafelmeier Date: Thu, 19 Mar 2026 14:24:16 +0100 Subject: [PATCH 4/4] test(ci): add error handling and output format tests --- .github/workflows/ci.yml | 48 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 87135f9..bc4e2ff 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -321,6 +321,54 @@ jobs: $BINARY_PATH --hostname=localhost --port=4010 --debug breeder list echo "✅ --debug flag works" + # === Error Handling Tests === + echo "" + echo "=== Testing Error Handling ===" + + # Test missing file + echo "Testing: missing file error" + if $BINARY_PATH --hostname=localhost --port=4010 breeder create --name=test --file=nonexistent.yml 2>/dev/null; then + echo "❌ Should have failed on missing file" + exit 1 + else + echo "✅ Failed on missing file as expected" + fi + + # Test missing required argument + echo "Testing: missing --id argument" + if $BINARY_PATH --hostname=localhost --port=4010 breeder show 2>/dev/null; then + echo "❌ Should have failed on missing --id" + exit 1 + else + echo "✅ Failed on missing --id as expected" + fi + + # === Output Format Tests === + echo "" + echo "=== Testing Output Formats ===" + + echo "Testing: JSON output format" + JSON_OUTPUT=$($BINARY_PATH --hostname=localhost --port=4010 --output=json breeder list) + if echo "$JSON_OUTPUT" | grep -q '"id"\|"name"\|"status"'; then + echo "✅ JSON output contains expected fields" + else + echo "❌ JSON output missing expected fields" + fi + + echo "Testing: YAML output format" + YAML_OUTPUT=$($BINARY_PATH --hostname=localhost --port=4010 --output=yaml breeder list) + if echo "$YAML_OUTPUT" | grep -q -e '^-' -e 'id:' -e 'name:'; then + echo "✅ YAML output contains expected fields" + else + echo "❌ YAML output missing expected fields" + fi + + echo "Testing: JSON output for breeder show" + $BINARY_PATH --hostname=localhost --port=4010 --output=json breeder show --id=550e8400-e29b-41d4-a716-446655440000 + + echo "Testing: YAML output for credential list" + $BINARY_PATH --hostname=localhost --port=4010 --output=yaml credential list + - name: Cleanup Prism container if: always() run: |