@@ -183,6 +183,7 @@ describe("ffprobe missing-binary fallback", () => {
183183
184184 it ( "spawns the configured absolute FFprobe path when HYPERFRAMES_FFPROBE_PATH is set" , async ( ) => {
185185 process . env . HYPERFRAMES_FFPROBE_PATH = "/tools/ffprobe.exe" ;
186+ const successfulStderr = "recoverable diagnostic on a successful probe" ;
186187 const { spawn, calls } = createSpawnSpy ( [
187188 {
188189 kind : "exit" ,
@@ -191,7 +192,7 @@ describe("ffprobe missing-binary fallback", () => {
191192 streams : [ { codec_type : "audio" , codec_name : "aac" , sample_rate : "48000" , channels : 2 } ] ,
192193 format : { duration : "1.25" , bit_rate : "128000" } ,
193194 } ) ,
194- stderr : "recoverable diagnostic on a successful probe" ,
195+ stderr : successfulStderr ,
195196 } ,
196197 ] ) ;
197198 vi . resetModules ( ) ;
@@ -201,6 +202,7 @@ describe("ffprobe missing-binary fallback", () => {
201202 const meta = await extractAudioMetadata ( "/tmp/uses-configured-ffprobe.wav" ) ;
202203
203204 expect ( meta . durationSeconds ) . toBe ( 1.25 ) ;
205+ expect ( JSON . stringify ( meta ) ) . not . toContain ( successfulStderr ) ;
204206 expect ( calls [ 0 ] ?. command ) . toBe ( resolve ( "/tools/ffprobe.exe" ) ) ;
205207 expect ( calls [ 0 ] ?. args . slice ( 0 , 2 ) ) . toEqual ( [ "-v" , "error" ] ) ;
206208 } ) ;
@@ -396,6 +398,34 @@ describe("ffprobe missing-binary fallback", () => {
396398 expect ( calls [ 0 ] ?. args . at ( - 1 ) ) . toBe ( inputPath ) ;
397399 } ) ;
398400
401+ it ( "redacts an input path fragment when the stderr tail starts inside its basename" , async ( ) => {
402+ const diagnostic = "Invalid data found when processing input" ;
403+ const inputPath = "/tmp/render/Confidential Client Preview.mp4" ;
404+ const retainedPathFragment = "Client Preview.mp4" ;
405+ const diagnosticPrefix = `: ${ diagnostic } ` ;
406+ const remainingBytes =
407+ 8 * 1024 - Buffer . byteLength ( retainedPathFragment ) - Buffer . byteLength ( diagnosticPrefix ) ;
408+ const multibyteCount = Math . floor ( remainingBytes / Buffer . byteLength ( "€" ) ) ;
409+ const trailingAscii = "x" . repeat ( remainingBytes - multibyteCount * Buffer . byteLength ( "€" ) ) ;
410+ const stderr = `${ inputPath } ${ diagnosticPrefix } ${ "€" . repeat ( multibyteCount ) } ${ trailingAscii } ` ;
411+ const { spawn } = createSpawnSpy ( [ { kind : "exit" , code : 1 , stderr } ] ) ;
412+ vi . resetModules ( ) ;
413+ vi . doMock ( "child_process" , ( ) => ( { spawn } ) ) ;
414+
415+ const { extractAudioMetadata } = await import ( "./ffprobe.js" ) ;
416+
417+ let thrown : unknown ;
418+ try {
419+ await extractAudioMetadata ( inputPath ) ;
420+ } catch ( error ) {
421+ thrown = error ;
422+ }
423+ expect ( String ( thrown ) ) . toContain ( diagnostic ) ;
424+ expect ( String ( thrown ) ) . toContain ( "[input]" ) ;
425+ expect ( String ( thrown ) ) . not . toContain ( retainedPathFragment ) ;
426+ expect ( String ( thrown ) ) . not . toContain ( "Client Preview.mp4" ) ;
427+ } ) ;
428+
399429 it ( "extractAudioMetadata surfaces a ffprobe-missing error verbatim" , async ( ) => {
400430 const { spawn, calls } = createSpawnSpy ( [ { kind : "missing" } ] ) ;
401431 hidePathBinaries ( ) ;
0 commit comments