{"record":{"id":"1ca787ccbffbda5c","repo":"phacility/phabricator","slug":"file-data-integrity-check-failed-use-salvage","errorCode":null,"errorMessage":"File data integrity check failed. Use \"--salvage\" to bypass integrity checks. This flag is dangerous, use it at your own risk. Underlying error: %s","messagePattern":"File data integrity check failed\\. Use \"--salvage\" to bypass integrity checks\\. This flag is dangerous, use it at your own risk\\. Underlying error: (.+?)","errorType":"console","errorClass":"PhutilArgumentUsageException","httpStatus":null,"severity":"critical","filePath":"src/applications/files/management/PhabricatorFilesManagementCatWorkflow.php","lineNumber":69,"sourceCode":"    $end = $args->getArg('end');\n\n    $file->makeEphemeral();\n\n    // If we're running in \"salvage\" mode, wipe out any integrity hash which\n    // may be present. This makes us read file data without performing an\n    // integrity check.\n    $salvage = $args->getArg('salvage');\n    if ($salvage) {\n      $file->setIntegrityHash(null);\n    }\n\n    try {\n      $iterator = $file->getFileDataIterator($begin, $end);\n      foreach ($iterator as $data) {\n        echo $data;\n      }\n    } catch (PhabricatorFileIntegrityException $ex) {\n      throw new PhutilArgumentUsageException(\n        pht(\n          'File data integrity check failed. Use \"--salvage\" to bypass '.\n          'integrity checks. This flag is dangerous, use it at your own '.\n          'risk. Underlying error: %s',\n          $ex->getMessage()));\n    }\n\n    return 0;\n  }\n\n}\n","sourceCodeStart":51,"sourceCodeEnd":81,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/files/management/PhabricatorFilesManagementCatWorkflow.php#L51-L81","documentation":"While streaming file data, getFileDataIterator() raised PhabricatorFileIntegrityException: the stored blob does not match the integrity hash recorded when the file was written. The cat workflow catches it and rethrows as a usage exception that advertises --salvage, which nulls the integrity hash and dumps the remaining bytes without verification. Data that fails this check should be treated as corrupted.","triggerScenarios":"Blob bytes changed in the storage engine (MySQL blob, disk, S3) after write: disk corruption, manual row edits, truncated objects, or a lossy storage migration; partial writes from interrupted uploads; --begin/--end ranges are fine, the check compares full content.","commonSituations":"Bit rot or filesystem damage under file storage; someone edited storage rows directly; S3 object replaced/truncated; copying storage between engines with a buggy script.","solutions":["If you must recover the bytes now, re-run with --salvage: `./bin/files cat --salvage F123` — output is unverified and may be damaged","Restore the file or its blob from backups and re-check","Investigate the storage engine for the corruption source (disk SMART, S3 consistency, DB replication) before trusting other files","If the original source still exists, re-upload the file"],"exampleFix":"# before\n./bin/files cat F123   # throws: integrity check failed\n\n# after (dangerous, bypasses verification)\n./bin/files cat --salvage F123","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  $iterator = $file->getFileDataIterator($begin, $end);\n  foreach ($iterator as $chunk) {\n    // consume verified data\n  }\n} catch (PhabricatorFileIntegrityException $ex) {\n  // Blob does not match its recorded hash: quarantine this PHID, alert,\n  // and fall back to backups. Do not silently serve the bytes.\n}","preventionTips":["Never hand-edit storage blobs or rows backing files","Run a periodic read sweep over stored files to surface integrity failures early","After storage migrations, verify hashes before decommissioning the source","Use --salvage only for one-off recovery, never in automated pipelines"],"tags":["integrity","corruption","storage","cli","files","phabricator"],"backgroundTag":"data-integrity-check-failed","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}