Skip to content

Commit 19adf58

Browse files
committed
Truncate long errors keeping the diagnostic tail
Drop the first 40% of long error messages (>80 chars) since the useful diagnostic info (e.g. PCR mismatches) sits at the end, after layers of generic wrapping.
1 parent 7160ab1 commit 19adf58

2 files changed

Lines changed: 40 additions & 2 deletions

File tree

cmd/workflow/logs/logs.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,9 @@ func (h *handler) printErrors(ctx context.Context, client *graphqlclient.Client,
288288
for _, ev := range resp.WorkflowExecutionEvents.Data {
289289
if ev.Status == "failure" && len(ev.Errors) > 0 {
290290
errMsg := ev.Errors[0].Error
291-
if len(errMsg) > 120 {
292-
errMsg = errMsg[:120] + "..."
291+
if len(errMsg) > 80 {
292+
start := len(errMsg) * 2 / 5 // drop first 40%, keep the diagnostic tail
293+
errMsg = "..." + errMsg[start:]
293294
}
294295
fmt.Printf(" -> %s: %s\n", ev.CapabilityID, errMsg)
295296
}

cmd/workflow/logs/logs_test.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,43 @@ func TestExecute(t *testing.T) {
180180
assert.Greater(t, failureIdx, successIdx, "oldest execution should appear first")
181181
})
182182

183+
t.Run("long error is truncated keeping tail", func(t *testing.T) {
184+
longErr := "failed to execute enclave request. enclave ID: abc123, error: attestation validation failed for ExecuteBatch: expected PCR0 deadbeef, got cafebabe"
185+
ts := newMockGraphQL(t, mockConfig{
186+
workflows: []map[string]any{
187+
{"uuid": "wf-1", "name": "test-workflow", "status": "ACTIVE"},
188+
},
189+
executions: []map[string]any{
190+
{
191+
"uuid": "exec-1",
192+
"status": "FAILURE",
193+
"startedAt": "2026-02-12T16:00:00Z",
194+
"finishedAt": "2026-02-12T16:00:01Z",
195+
},
196+
},
197+
events: []map[string]any{
198+
{
199+
"capabilityID": "confidential-http@1.0.0",
200+
"status": "failure",
201+
"errors": []map[string]any{{"error": longErr, "count": 1}},
202+
},
203+
},
204+
})
205+
defer ts.Close()
206+
207+
output := captureStdout(t, func() {
208+
h := newTestHandler(ts.URL, "test-workflow", false, 10)
209+
err := h.Execute(context.Background())
210+
require.NoError(t, err)
211+
})
212+
213+
// The diagnostic tail should survive truncation
214+
assert.Contains(t, output, "expected PCR0 deadbeef, got cafebabe")
215+
// The generic prefix should be dropped
216+
assert.NotContains(t, output, "failed to execute enclave request")
217+
assert.Contains(t, output, "...")
218+
})
219+
183220
t.Run("workflow not found", func(t *testing.T) {
184221
ts := newMockGraphQL(t, mockConfig{})
185222
defer ts.Close()

0 commit comments

Comments
 (0)