From f4f02b0e2ecc3059ad0a84698c1331350fe42ffa129763fa347b9779f60d9ff2 Mon Sep 17 00:00:00 2001 From: Tyler J King Date: Wed, 13 May 2026 08:32:16 -0400 Subject: [PATCH] debug(gsap-attestor): include raw input and both parse errors in diagnostics MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Temporary diagnostic commit — surfaces the exact data SPIRE sends to the Configure RPC so we can determine why JSON decode fails. Co-Authored-By: Claude Opus 4.6 --- cmd/gsap-attestor/main.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/cmd/gsap-attestor/main.go b/cmd/gsap-attestor/main.go index 726a79f..7598344 100644 --- a/cmd/gsap-attestor/main.go +++ b/cmd/gsap-attestor/main.go @@ -2,6 +2,7 @@ package main import ( "context" + "fmt" "sync" "github.com/hashicorp/hcl/v2/hclsimple" @@ -41,12 +42,15 @@ func (p *Plugin) Attest(ctx context.Context, req *workloadattestorv1.AttestReque func decodeConfig(data string) (GsapAttestorConfig, error) { var cfg GsapAttestorConfig - if err := hclsimple.Decode("plugin.json", []byte(data), nil, &cfg); err != nil { - if err2 := hclsimple.Decode("plugin.hcl", []byte(data), nil, &cfg); err2 != nil { - return cfg, err2 - } + jsonErr := hclsimple.Decode("plugin.json", []byte(data), nil, &cfg) + if jsonErr == nil { + return cfg, nil } - return cfg, nil + hclErr := hclsimple.Decode("plugin.hcl", []byte(data), nil, &cfg) + if hclErr == nil { + return cfg, nil + } + return cfg, fmt.Errorf("json: %v; hcl: %v; raw input: %q", jsonErr, hclErr, data) } func (p *Plugin) Configure(_ context.Context, req *configv1.ConfigureRequest) (*configv1.ConfigureResponse, error) {