Skip to content

fix(client): surface nested error bodies and implement --debug#16

Merged
vks-team merged 1 commit into
mainfrom
fix/error-surfacing-debug
Jun 13, 2026
Merged

fix(client): surface nested error bodies and implement --debug#16
vks-team merged 1 commit into
mainfrom
fix/error-surfacing-debug

Conversation

@vks-team

Copy link
Copy Markdown
Contributor

Summary

While running grn vks generate-kubeconfig, a real server validation error was hidden behind a bare API error (HTTP 400 Bad Request). Two client deficiencies caused this:

  1. Nested error bodies were dropped. The VKS API returns {"error":{"message":...}} (a nested object). formatError only extracted error when it was a string, so the message was lost. Added a raw-body fallback so the server's message is always surfaced.
  2. --debug was a no-op. The debug flag was stored but never used. Now logs request method/URL/body and response status/body to stderr.

With the fix, the same call shows the actual reason:

[debug] response 400: {"error":{"message":"KubeConfig can only be requested when the cluster is ACTIVE, UPDATING, or WAITING_UPDATE."}}

Test Plan

  • go test ./internal/client/ — new TestFormatErrorSurfacesNestedErrorObject, TestFormatErrorUsesPlainStringMessage, existing tests PASS
  • go vet ./... clean; build clean
  • Manual: grn vks generate-kubeconfig --debug now prints request/response and the nested error message

Tests on macOS 26 + Go 1.22.2 need the external linker: CGO_ENABLED=1 go test -ldflags='-linkmode=external' ./...

🤖 Generated with Claude Code

The VKS API returns errors as {"error":{"message":...}} (nested object).
formatError only handled string fields, so users saw a bare
"API error (HTTP 400 Bad Request)" with no detail. Add a raw-body fallback.

Also wire up the previously-unused --debug flag to log request
method/URL/body and response status/body to stderr.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vks-team vks-team merged commit 9a76302 into main Jun 13, 2026
4 checks passed
@vks-team vks-team deleted the fix/error-surfacing-debug branch June 13, 2026 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant