{"record":{"id":"8d2826460811c2d8","repo":"siyuan-note/siyuan","slug":"cli-does-not-support-files-in-encrypted-notebooks","errorCode":null,"errorMessage":"CLI does not support files in encrypted notebooks","messagePattern":"CLI does not support files in encrypted notebooks","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/cli/cmd/root.go","lineNumber":176,"sourceCode":"\t\tif flag == nil {\n\t\t\tcontinue\n\t\t}\n\t\tvalues := []string{flag.Value.String()}\n\t\tif flag.Value.Type() == \"stringArray\" {\n\t\t\tvalues, _ = cmd.Flags().GetStringArray(flagName)\n\t\t}\n\t\tfor _, value := range values {\n\t\t\tfor id := range strings.SplitSeq(value, \",\") {\n\t\t\t\tif checkID(strings.TrimSpace(id)) {\n\t\t\t\t\treturn fmt.Errorf(\"CLI does not support encrypted notebook [%s]\", encryptedTarget)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif cmd.Parent() == fileCmd {\n\t\tif slices.ContainsFunc(args, isEncryptedNotebookWorkspacePath) {\n\t\t\treturn fmt.Errorf(\"CLI does not support files in encrypted notebooks\")\n\t\t}\n\t\tif pathFlag := cmd.Flags().Lookup(\"path\"); pathFlag != nil && pathFlag.Value.String() != \"\" && isEncryptedNotebookWorkspacePath(pathFlag.Value.String()) {\n\t\t\treturn fmt.Errorf(\"CLI does not support files in encrypted notebooks\")\n\t\t}\n\t}\n\tif cmd.Parent() == assetCmd {\n\t\tif pathFlag := cmd.Flags().Lookup(\"path\"); pathFlag != nil && pathFlag.Value.String() != \"\" {\n\t\t\tassetPath := pathFlag.Value.String()\n\t\t\tif !filepath.IsAbs(assetPath) {\n\t\t\t\tassetPath = filepath.Join(\"data\", assetPath)\n\t\t\t}\n\t\t\tif isEncryptedNotebookWorkspacePath(assetPath) {\n\t\t\t\treturn fmt.Errorf(\"CLI does not support files in encrypted notebooks\")\n\t\t\t}\n\t\t}\n\t}\n\tif cmd == historyGetCmd || cmd == historyRollbackCmd {\n\t\thistoryPath, _ := cmd.Flags().GetString(\"path\")","sourceCodeStart":158,"sourceCodeEnd":194,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/cli/cmd/root.go#L158-L194","documentation":"For commands under the `file` subcommand, the CLI checks positional arguments against isEncryptedNotebookWorkspacePath, which resolves a path (relative paths against the workspace) into data/<boxID>/... and tests whether that box ID is an encrypted notebook. If any positional argument lies inside an encrypted notebook directory, the command aborts.","triggerScenarios":"Running any `SiYuan-Kernel file ...` subcommand with a positional argument that resolves to a path under data/<encrypted-box-id>/ — e.g. passing data/20240101120000-enc1/foo.sy as an argument.","commonSituations":"Scripting file operations over data/ contents without excluding encrypted notebook directories; reusing old scripts written before notebooks were encrypted; tab-completed paths that include encrypted notebook folders.","solutions":["Remove or replace arguments that point inside the encrypted notebook directory.","Perform the file operation in the SiYuan app, which supports encrypted notebooks natively.","Temporarily relocate the encrypted notebook (app-supported) or exclude its box directory from your script's path list."],"exampleFix":"// before\nSiYuan-Kernel file get \"data/20240101120000-enc1/foo.sy\"\n// after: use a path in a normal notebook\nSiYuan-Kernel file get \"data/20240101120000-plain/foo.sy\"","handlingStrategy":"validation","validationCode":"// Go: ensure a data path's top-level box directory is not an encrypted notebook\nbox := strings.SplitN(relToData, string(filepath.Separator), 2)[0]\nif isEncryptedBox(box) { return skip }","typeGuard":null,"tryCatchPattern":"if err := runKernelCLI(args); err != nil && strings.Contains(err.Error(), \"files in encrypted notebooks\") {\n    // exclude that path from the argument list and retry\n}","preventionTips":["Enumerate only non-encrypted box directories when generating file arguments.","Never feed raw data/ listings to file subcommands without filtering by notebook.","Audit paths after any notebook is converted to an encrypted notebook."],"tags":["cli","encryption","file"],"backgroundTag":"unsupported-operation","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}