From 777e460fd0f04d3377393e4d5d240e36056e96d0 Mon Sep 17 00:00:00 2001 From: Chris Huber Date: Fri, 16 Oct 2026 16:10:02 -0400 Subject: [PATCH] Fill in block validation messages' placeholders --- apps/cli/ai/block-validator.ts | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/apps/cli/ai/block-validator.ts b/apps/cli/ai/block-validator.ts index defad741e2..d41d2ceb7c 100644 --- a/apps/cli/ai/block-validator.ts +++ b/apps/cli/ai/block-validator.ts @@ -72,6 +72,18 @@ export async function validateBlocks( }; } + // Block validation logs console-style messages: a format string whose + // %s / %o / %d placeholders take the arguments that follow it. + function formatIssue( args: any[] ): string { + const show = ( value: any ) => + typeof value === 'object' ? JSON.stringify( value ) : String( value ); + const rest = args.slice( 1 ); + const text = String( args[ 0 ] ?? '' ).replace( /%[sodif]/g, ( placeholder ) => + rest.length ? show( rest.shift() ) : placeholder + ); + return [ text, ...rest.map( show ) ].join( ' ' ).slice( 0, 600 ); + } + function extractIssues( validationIssues: any[] ): string[] { const issues: string[] = []; for ( const issue of validationIssues ) { @@ -80,15 +92,7 @@ export async function validateBlocks( // Skip the verbose "Block validation failed for `name`" summary — // the per-attribute messages that follow are more useful. if ( ! msg.startsWith( 'Block validation failed' ) ) { - issues.push( - issue.args - .map( ( a: any ) => - typeof a === 'object' - ? JSON.stringify( a ).slice( 0, 200 ) - : String( a ).slice( 0, 500 ) - ) - .join( ' ' ) - ); + issues.push( formatIssue( issue.args ) ); } } }