@@ -415,6 +415,78 @@ func TestSQLiteReader_GetLogsFiltersByUserPathSubtree(t *testing.T) {
415415 }
416416}
417417
418+ func TestSQLiteReader_GetLogsRootUserPathIncludesLegacyNullRows (t * testing.T ) {
419+ db := createTestDB (t )
420+ defer db .Close ()
421+
422+ store , err := NewSQLiteStore (db , 0 )
423+ if err != nil {
424+ t .Fatalf ("failed to create store: %v" , err )
425+ }
426+ defer store .Close ()
427+
428+ now := time .Now ().UTC ().Format (time .RFC3339Nano )
429+ _ , err = db .Exec (`
430+ INSERT INTO audit_logs (
431+ id, timestamp, duration_ns, model, resolved_model, provider, alias_used, execution_plan_version_id,
432+ status_code, request_id, client_ip, method, path, user_path, stream, error_type, data
433+ ) VALUES
434+ (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?),
435+ (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
436+ ` ,
437+ "legacy-null" ,
438+ now ,
439+ 0 ,
440+ "gpt-4" ,
441+ "" ,
442+ "openai" ,
443+ 0 ,
444+ nil ,
445+ 200 ,
446+ "req-legacy" ,
447+ "127.0.0.1" ,
448+ "POST" ,
449+ "/v1/chat/completions" ,
450+ nil ,
451+ 0 ,
452+ "" ,
453+ nil ,
454+ "root-explicit" ,
455+ now ,
456+ 0 ,
457+ "gpt-4" ,
458+ "" ,
459+ "openai" ,
460+ 0 ,
461+ nil ,
462+ 200 ,
463+ "req-root" ,
464+ "127.0.0.1" ,
465+ "POST" ,
466+ "/v1/chat/completions" ,
467+ "/" ,
468+ 0 ,
469+ "" ,
470+ nil ,
471+ )
472+ if err != nil {
473+ t .Fatalf ("failed to insert audit log rows: %v" , err )
474+ }
475+
476+ reader , err := NewSQLiteReader (db )
477+ if err != nil {
478+ t .Fatalf ("failed to create reader: %v" , err )
479+ }
480+
481+ logs , err := reader .GetLogs (context .Background (), LogQueryParams {UserPath : "/" , Limit : 10 })
482+ if err != nil {
483+ t .Fatalf ("GetLogs failed: %v" , err )
484+ }
485+ if len (logs .Entries ) != 2 {
486+ t .Fatalf ("len(entries) = %d, want 2" , len (logs .Entries ))
487+ }
488+ }
489+
418490func TestSQLiteStoreAndReader_PreserveCacheType (t * testing.T ) {
419491 db := createTestDB (t )
420492 defer db .Close ()
0 commit comments