@@ -317,33 +317,31 @@ export const BackupValidator = {
317
317
return false ;
318
318
}
319
319
320
- // Must have either:
321
- // 1. PartitionKey and RowKey (Azure Table format)
322
- // 2. id field (some backup formats)
323
- // 3. At least 2 string properties (fallback for partial data)
324
- const hasAzureKeys = row . PartitionKey && row . RowKey ;
325
- const hasId = row . id ;
326
- const stringProps = Object . values ( row ) . filter ( ( v ) => typeof v === "string" ) . length ;
327
-
328
- if ( hasAzureKeys || hasId || stringProps >= 2 ) {
329
- // Additional checks for obvious corruption
330
- const rowJson = JSON . stringify ( row ) ;
331
-
332
- // Skip rows that are way too large (likely corrupted)
333
- if ( rowJson . length > 10000000 ) {
334
- // 10MB limit
335
- return false ;
336
- }
320
+ // Must have all three required properties for CIPP table storage
321
+ const hasTable = row . table && typeof row . table === "string" ;
322
+ const hasPartitionKey = row . PartitionKey && typeof row . PartitionKey === "string" ;
323
+ const hasRowKey = row . RowKey && typeof row . RowKey === "string" ;
337
324
338
- // Skip rows with null bytes (always corruption)
339
- if ( rowJson . includes ( "\0" ) ) {
340
- return false ;
341
- }
325
+ // All three are required for valid CIPP backup row
326
+ if ( ! hasTable || ! hasPartitionKey || ! hasRowKey ) {
327
+ return false ;
328
+ }
342
329
343
- return true ;
330
+ // Additional checks for obvious corruption
331
+ const rowJson = JSON . stringify ( row ) ;
332
+
333
+ // Skip rows that are way too large (likely corrupted)
334
+ if ( rowJson . length > 10000000 ) {
335
+ // 10MB limit
336
+ return false ;
344
337
}
345
338
346
- return false ;
339
+ // Skip rows with null bytes (always corruption)
340
+ if ( rowJson . includes ( "\0" ) ) {
341
+ return false ;
342
+ }
343
+
344
+ return true ;
347
345
} ,
348
346
349
347
/**
@@ -354,11 +352,20 @@ export const BackupValidator = {
354
352
return "Not a valid object" ;
355
353
}
356
354
357
- if ( ! row . PartitionKey && ! row . RowKey && ! row . id ) {
358
- const stringProps = Object . values ( row ) . filter ( ( v ) => typeof v === "string" ) . length ;
359
- if ( stringProps < 2 ) {
360
- return "Missing required identifiers and insufficient data" ;
361
- }
355
+ // Check for missing required CIPP backup properties
356
+ const missingFields = [ ] ;
357
+ if ( ! row . table || typeof row . table !== "string" ) {
358
+ missingFields . push ( "table" ) ;
359
+ }
360
+ if ( ! row . PartitionKey || typeof row . PartitionKey !== "string" ) {
361
+ missingFields . push ( "PartitionKey" ) ;
362
+ }
363
+ if ( ! row . RowKey || typeof row . RowKey !== "string" ) {
364
+ missingFields . push ( "RowKey" ) ;
365
+ }
366
+
367
+ if ( missingFields . length > 0 ) {
368
+ return `Missing required fields: ${ missingFields . join ( ", " ) } ` ;
362
369
}
363
370
364
371
const rowJson = JSON . stringify ( row ) ;
0 commit comments