Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions packages/cli/src/list-command.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,34 @@ test('formatDeploymentsTable collapses and bounds multiline error details', () =
assert.match(out, /\.\.\./);
});

test('formatDeploymentsTable snippets past an elision marker instead of repeating boilerplate', () => {
// cloud's deployment-run-failure-class.ts stores unrecognized long failures
// as `<boilerplate>...[N chars omitted]...<real cause>` so the real cause
// survives its own 10_000-char truncation. Naively slicing from position 0
// here would show only the boilerplate every time and never reach it.
const boilerplate = '[smithy-diag] node=v25.6.0 '.repeat(20);
const realCause = 'unexpected teardown error: mount flush wedged past the deadline';
const longError = `${boilerplate}...[9153 chars omitted]...${realCause}`;
const out = formatDeploymentsTable([
{
agentId: 'agent-elided-error',
personaId: 'elided-error',
personaSlug: 'elided-error',
deployedName: 'elided-error',
status: 'active',
createdAt: '2026-09-17T00:00:00.000Z',
lastUsedAt: null,
lastRunStatus: 'failed',
lastError: longError,
scheduleIds: [],
deployedByUserId: 'user-1'
}
]);

assert.match(out, /elided-error: unexpected teardown error: mount flush wedged past the deadline/);
assert.doesNotMatch(out, /smithy-diag/);
});

test('parseDeploymentLogsArgs accepts selector and log flags', () => {
assert.deepEqual(
parseDeploymentLogsArgs([
Expand Down
17 changes: 17 additions & 0 deletions packages/cli/src/list-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -591,12 +591,29 @@ function readFiniteNumber(record: Record<string, unknown>, key: string): number

const DEPLOYMENT_ERROR_SNIPPET_LENGTH = 240;

// cloud's deployment-run-failure-class.ts marks an unrecognized long failure
// as "<head>...[N chars omitted]...<tail>" (head = boilerplate mount/smithy
// bootstrap that runs before every persona invocation, tail = whatever
// actually happened). Truncating from position 0 below would always show the
// boilerplate and never reach the tail where the real cause lives, so when
// this marker is present, snippet from just after it instead.
const OMITTED_MARKER_PATTERN = /\.\.\.\[\d+ chars omitted\]\.\.\./;

function formatDeploymentErrorSnippet(error: string): string {
const normalized = error
.replace(/[\u0000-\u001f\u007f]+/g, ' ')
.replace(/\s+/g, ' ')
.trim();
if (normalized.length <= DEPLOYMENT_ERROR_SNIPPET_LENGTH) return normalized;
const marker = normalized.match(OMITTED_MARKER_PATTERN);
if (marker && marker.index !== undefined) {
const afterMarker = normalized.slice(marker.index + marker[0].length).trim();
if (afterMarker.length > 0) {
return afterMarker.length <= DEPLOYMENT_ERROR_SNIPPET_LENGTH
? afterMarker
: `${afterMarker.slice(0, DEPLOYMENT_ERROR_SNIPPET_LENGTH - 3)}...`;
}
}
return `${normalized.slice(0, DEPLOYMENT_ERROR_SNIPPET_LENGTH - 3)}...`;
}

Expand Down
Loading