{"record":{"id":"17d2cb24225c7570","repo":"linshenkx/prompt-optimizer","slug":"label-resource-validation-failed-formatimage","errorCode":null,"errorMessage":"${label} resource validation failed: ${formatImageResourceRestoreProblemDetails(report)}","messagePattern":"(.+?) resource validation failed: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/ui/src/utils/image-resource-backup.ts","lineNumber":239,"sourceCode":"\nexport const formatImageResourceRestoreProblemDetails = <Problem>(\n  report: ImageResourceRestoreReport<Problem>,\n): string =>\n  [\n    report.missing.length ? `missing=${report.missing.length}` : '',\n    report.corrupt.length ? `corrupt=${report.corrupt.length}` : '',\n    report.errors.length ? `errors=${report.errors.length}` : '',\n  ].filter(Boolean).join(', ')\n\nexport const assertImageResourceRestoreReportSafe = <Problem>(\n  report: ImageResourceRestoreReport<Problem>,\n  label: string,\n): void => {\n  if (!hasImageResourceRestoreProblems(report)) {\n    return\n  }\n\n  throw new Error(`${label} resource validation failed: ${formatImageResourceRestoreProblemDetails(report)}`)\n}\n","sourceCodeStart":221,"sourceCodeEnd":241,"githubUrl":"https://github.com/linshenkx/prompt-optimizer/blob/3e677b1d9f7e0493c142c175560531e7ae786dce/packages/ui/src/utils/image-resource-backup.ts#L221-L241","documentation":"Thrown by assertImageResourceRestoreReportSafe when a restore-validation report for image resources contains problems. After restoring a backup, the library validates that referenced image resources are intact; if any resource is missing, corrupt, or unresolvable the report is non-empty and this error is raised with a formatted list of problem details.","triggerScenarios":"Restoring a remote/local backup where referenced image blobs were not restored, have mismatched hashes or sizes, or reference manifests point to absent resources; partial backup uploads or interrupted restores producing incomplete resource sets.","commonSituations":"Backup taken while images were being written (torn snapshot); interrupted upload leaving some image objects missing in Drive/S3; restore performed against a different account or bucket lacking referenced objects; schema/version drift between backup versions.","solutions":["Read the formatted problem details in the message to identify which resources failed and why","Re-run or complete the backup upload so all referenced image resources exist in the remote store","Restore from an earlier known-good backup snapshot","If resources were intentionally deleted, prune dangling references from the backup index before validating"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import { hasImageResourceRestoreProblems } from '<package>/utils/image-resource-backup'\n\nif (hasImageResourceRestoreProblems(report)) {\n  // inspect report problems before asserting; log, alert, or abort restore\n  console.warn('restore problems', report)\n}","typeGuard":null,"tryCatchPattern":"try {\n  assertImageResourceRestoreReportSafe(report, 'backup restore')\n} catch (error) {\n  // message contains per-resource problem details; surface to user and keep previous data\n  reportRestoreFailure((error as Error).message)\n}","preventionTips":["Run hasImageResourceRestoreProblems check first and branch on it instead of asserting blindly","Validate backup integrity right after upload, not only at restore time","Never delete local data until restore validation passes"],"tags":["backup-restore","validation","image-resources","data-integrity"],"backgroundTag":"backup-restore-validation-failed","analyzedSha":"3e677b1d9f7e0493c142c175560531e7ae786dce","analyzedAt":"2026-08-27T21:29:16.709Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}