{"record":{"id":"ddc8115af6436cb1","repo":"kopia/kopia","slug":"unknown-mode-v","errorCode":null,"errorMessage":"unknown mode %v","messagePattern":"unknown mode (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/command_restore.go","lineNumber":313,"sourceCode":"\n\tcase restoreModeTar:\n\t\tf, err := os.Create(targetpath) //nolint:gosec\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrap(err, \"unable to create output file\")\n\t\t}\n\n\t\treturn restore.NewTarOutput(f), nil\n\n\tcase restoreModeTgz:\n\t\tf, err := os.Create(targetpath) //nolint:gosec\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrap(err, \"unable to create output file\")\n\t\t}\n\n\t\treturn restore.NewTarOutput(gzip.NewWriter(f)), nil\n\n\tdefault:\n\t\treturn nil, errors.Errorf(\"unknown mode %v\", m)\n\t}\n}\n\nfunc (c *commandRestore) detectRestoreMode(ctx context.Context, m, targetpath string) string {\n\tif m != \"auto\" {\n\t\treturn m\n\t}\n\n\tswitch {\n\tcase strings.HasSuffix(targetpath, \".zip\"):\n\t\tlog(ctx).Infof(\"Restoring to a zip file (%v)...\", targetpath)\n\t\treturn restoreModeZip\n\n\tcase strings.HasSuffix(targetpath, \".tar\"):\n\t\tlog(ctx).Infof(\"Restoring to an uncompressed tar file (%v)...\", targetpath)\n\t\treturn restoreModeTar\n\n\tcase strings.HasSuffix(targetpath, \".tar.gz\") || strings.HasSuffix(targetpath, \".tgz\"):","sourceCodeStart":295,"sourceCodeEnd":331,"githubUrl":"https://github.com/kopia/kopia/blob/82495e54b584c1ef6073c9e1be048f57f8aef078/cli/command_restore.go#L295-L331","documentation":"restoreOutput returns errors.Errorf(\"unknown mode %v\", m) when the --mode flag value does not match any supported restore mode (local, zip, zip-no-compress, tar, tgz, or a value auto-detected to one of those). It is a guard against unsupported mode strings.","triggerScenarios":"Passing an unrecognized --mode value to `kopia restore`, e.g. --mode ziped, --mode gzip, or a typo; detectRestoreMode passes through any non-\"auto\" value unvalidated.","commonSituations":"Typo in the --mode flag in a script or alias; copying a mode name from another backup tool (e.g. 'tgz2', 'zstd'); older Kopia version lacking a newer mode name.","solutions":["Check `kopia restore --help` and use an exact supported mode: local, zip, zip-no-compress, tar, or tgz.","Fix the typo in the --mode flag value.","Use --mode auto (the default) to let Kopia detect the mode from the target path.","Upgrade Kopia if the mode you want was added in a newer release."],"exampleFix":"// before\nkopia restore --mode ziped kff82b1d... /tmp/out.zip\n// after\nkopia restore --mode zip kff82b1d... /tmp/out.zip","handlingStrategy":"validation","validationCode":"const VALID_MODES = ['auto', 'local', 'zip', 'zip-no-compress', 'tar', 'tgz'];\nif (!VALID_MODES.includes(mode)) throw new Error(`invalid --mode '${mode}'; expected one of ${VALID_MODES.join(', ')}`);","typeGuard":null,"tryCatchPattern":"try {\n  await kopiaRestore({ mode, source, target });\n} catch (err) {\n  if (/unknown mode/.test(String(err))) {\n    console.error(`Mode '${mode}' unsupported; use one of: local, zip, zip-no-compress, tar, tgz`);\n  }\n  throw err;\n}","preventionTips":["Copy --mode values from `kopia restore --help` rather than from memory.","Prefer the default --mode auto in scripts.","Lint CI scripts against the set of valid mode strings."],"tags":["cli","validation","restore","flags"],"backgroundTag":"invalid-enum-value","analyzedSha":"82495e54b584c1ef6073c9e1be048f57f8aef078","analyzedAt":"2026-09-07T20:35:21.689Z","contentChangedAt":"2026-09-07T20:35:21.689Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}