{"record":{"id":"eb9186b2b82210d3","repo":"strapi/strapi","slug":"file-filepath-is-not-a-valid-strapi-data-file","errorCode":null,"errorMessage":"File '${filePath}' is not a valid Strapi data file.","messagePattern":"File '(.+?)' is not a valid Strapi data file\\.","errorType":"exception","errorClass":"ProviderInitializationError","httpStatus":null,"severity":"error","filePath":"packages/core/data-transfer/src/file/providers/source/index.ts","lineNumber":123,"sourceCode":"\n  /**\n   * Pre flight checks regarding the provided options, making sure that the file can be opened (decrypted, decompressed), etc.\n   */\n  async bootstrap(diagnostics: IDiagnosticReporter) {\n    this.#diagnostics = diagnostics;\n    const { path: filePath } = this.options.file;\n\n    try {\n      // Read the metadata to ensure the file can be parsed\n      await this.#loadMetadata();\n      // TODO: we might also need to read the schema.jsonl files & implements a custom stream-check\n    } catch {\n      if (this.options?.encryption?.enabled) {\n        throw new ProviderInitializationError(\n          `Key is incorrect or the file '${filePath}' is not a valid Strapi data file.`\n        );\n      }\n      throw new ProviderInitializationError(`File '${filePath}' is not a valid Strapi data file.`);\n    }\n\n    if (!this.#metadata) {\n      throw new ProviderInitializationError('Could not load metadata from Strapi data file.');\n    }\n  }\n\n  async #loadMetadata() {\n    const backupStream = this.#getBackupStream();\n    this.#metadata = await this.#parseJSONFile<IMetadata>(backupStream, METADATA_FILE_PATH);\n  }\n\n  async #loadAssetMetadata(path: string) {\n    const backupStream = this.#getBackupStream();\n    return this.#parseJSONFile<IFile>(backupStream, path);\n  }\n\n  async getMetadata() {","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/strapi/strapi/blob/4a4101264d7098754df36e85fa629fd2f2349d8c/packages/core/data-transfer/src/file/providers/source/index.ts#L105-L141","documentation":"ProviderInitializationError thrown in bootstrap() when #loadMetadata() throws AND encryption is disabled. The file could not be parsed as a Strapi data archive and, since no decryption was attempted, the message attributes the failure to the file itself being invalid.","triggerScenarios":"File source bootstrap reads metadata and the underlying stream/JSON parse fails with encryption.enabled = false. Most often the path points to a non-.data file, a corrupted file, or a file from an incompatible Strapi version.","commonSituations":"Pointing file.path at the wrong file (a zip, a log, a partial download), an interrupted export that produced a truncated archive, an old v3/v4 export the current code cannot parse, or a file written by a different tool.","solutions":["Confirm the path points to a Strapi .data file produced by a compatible data-transfer version.","Re-create the export from the source instance.","Verify the file is not truncated/corrupted (compare size/checksum with source).","If the file is actually encrypted, set encryption.enabled = true and supply the key."],"exampleFix":"// before\ncreateLocalFileSourceProvider({ file: { path: './some-random-file' } });\n\n// after\ncreateLocalFileSourceProvider({ file: { path: './exports/backup-2024-01-01.data' } });","handlingStrategy":"validation","validationCode":"import { statSync } from 'fs';\nconst s = statSync(options.file.path);\nif (!s.isFile() || s.size < 1024) throw new Error('File does not look like a Strapi data export');","typeGuard":"function isInvalidFileError(e: unknown): boolean {\n  return e instanceof Error && /is not a valid Strapi data file/.test(e.message);\n}","tryCatchPattern":"try {\n  await sourceProvider.bootstrap(diag);\n} catch (e) {\n  if (/not a valid Strapi data file/.test(e.message)) return { invalidFile: true };\n  throw e;\n}","preventionTips":["Verify the file path is a real Strapi .data file before running the import.","Compare file checksums with the export source.","Keep export and import Strapi major versions aligned."],"tags":["data-transfer","initialization","file-source","corruption"],"backgroundTag":null,"analyzedSha":"4a4101264d7098754df36e85fa629fd2f2349d8c","analyzedAt":"2026-08-12T12:47:50.760Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}