From 5661ed025fb26e89230ec1f652602b08ed7f5a11 Mon Sep 17 00:00:00 2001 From: Julien Biezemans Date: Fri, 27 Mar 2026 16:22:38 +0100 Subject: [PATCH] fix: serialize type_schema as JSON in attestation type table output The server now returns type_schema as a JSON object instead of a Python repr string. The CLI was printing it with fmt %s, producing Go's map representation. Marshal it back to JSON for proper display. Co-Authored-By: Claude Opus 4.6 (1M context) --- cmd/kosli/getAttestationType.go | 6 +++++- .../testdata/output/get/get-archived-attestation-type.txt | 2 +- .../testdata/output/get/get-attestation-type-version.txt | 2 +- cmd/kosli/testdata/output/get/get-attestation-type.txt | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/cmd/kosli/getAttestationType.go b/cmd/kosli/getAttestationType.go index 428edaaad..93f4ff74b 100644 --- a/cmd/kosli/getAttestationType.go +++ b/cmd/kosli/getAttestationType.go @@ -172,7 +172,11 @@ func printVersionedAttestationTypeAsTable(raw map[string]interface{}, rows []str rows = append(rows, fmt.Sprintf(" Created By:\t%s", attestationType["created_by"])) if typeSchema, ok := attestationType["type_schema"]; ok { - rows = append(rows, fmt.Sprintf(" Type schema:\t%s", typeSchema)) + typeSchemaJSON, err := json.Marshal(typeSchema) + if err != nil { + return []string{}, err + } + rows = append(rows, fmt.Sprintf(" Type schema:\t%s", string(typeSchemaJSON))) } if evaluator, ok := attestationType["evaluator"].(map[string]interface{}); ok { diff --git a/cmd/kosli/testdata/output/get/get-archived-attestation-type.txt b/cmd/kosli/testdata/output/get/get-archived-attestation-type.txt index 1ae52944e..3b1bed2d7 100644 --- a/cmd/kosli/testdata/output/get/get-archived-attestation-type.txt +++ b/cmd/kosli/testdata/output/get/get-archived-attestation-type.txt @@ -8,7 +8,7 @@ Versions: Version: 1 Timestamp: Sat, 16 Jan 2016 00:00:00 UTC • 2016-01-16 Created By: docs-cmd-test-user - Type schema: {'type': 'object', 'additionalProperties': True, 'properties': {'name': {'type': 'string'}, 'age': {'type': 'integer'}}} + Type schema: \{"additionalProperties":true,"properties":\{"age":\{"type":"integer"\},"name":\{"type":"string"\}\},"type":"object"\} Evaluator: Content Type: jq Rules: diff --git a/cmd/kosli/testdata/output/get/get-attestation-type-version.txt b/cmd/kosli/testdata/output/get/get-attestation-type-version.txt index adc44068b..9d016f561 100644 --- a/cmd/kosli/testdata/output/get/get-attestation-type-version.txt +++ b/cmd/kosli/testdata/output/get/get-attestation-type-version.txt @@ -5,7 +5,7 @@ Versions: Version: 1 Timestamp: Sat, 16 Jan 2016 00:00:00 UTC • 2016-01-16 Created By: docs-cmd-test-user - Type schema: {'type': 'object', 'additionalProperties': True, 'properties': {'name': {'type': 'string'}, 'age': {'type': 'integer'}}} + Type schema: \{"additionalProperties":true,"properties":\{"age":\{"type":"integer"\},"name":\{"type":"string"\}\},"type":"object"\} Evaluator: Content Type: jq Rules: diff --git a/cmd/kosli/testdata/output/get/get-attestation-type.txt b/cmd/kosli/testdata/output/get/get-attestation-type.txt index fbdc0cdf8..3957f0874 100644 --- a/cmd/kosli/testdata/output/get/get-attestation-type.txt +++ b/cmd/kosli/testdata/output/get/get-attestation-type.txt @@ -8,7 +8,7 @@ Versions: Version: 1 Timestamp: Sat, 16 Jan 2016 00:00:00 UTC • 2016-01-16 Created By: docs-cmd-test-user - Type schema: {'type': 'object', 'additionalProperties': True, 'properties': {'name': {'type': 'string'}, 'age': {'type': 'integer'}}} + Type schema: \{"additionalProperties":true,"properties":\{"age":\{"type":"integer"\},"name":\{"type":"string"\}\},"type":"object"\} Evaluator: Content Type: jq Rules: