{"record":{"id":"53aca078b7436ba5","repo":"siyuan-note/siyuan","slug":"write-pandoc-docx-filter-w","errorCode":null,"errorMessage":"write pandoc docx filter: %w","messagePattern":"write pandoc docx filter: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/pandoc_docx_filter.go","lineNumber":34,"sourceCode":"\npackage model\n\nimport (\n\t_ \"embed\"\n\t\"fmt\"\n\t\"os\"\n\t\"path/filepath\"\n)\n\nconst pandocDocxFilterName = \"siyuan-docx-filter.lua\"\n\n//go:embed pandoc_docx_filter.lua\nvar pandocDocxFilter []byte\n\nfunc writePandocDocxFilter(dir string) (string, error) {\n\tfilterPath := filepath.Join(dir, pandocDocxFilterName)\n\tif err := os.WriteFile(filterPath, pandocDocxFilter, 0600); err != nil {\n\t\treturn \"\", fmt.Errorf(\"write pandoc docx filter: %w\", err)\n\t}\n\treturn filterPath, nil\n}\n\nfunc appendBuiltinPandocDocxFilter(args []string, filterPath string) []string {\n\treturn append(args, \"--lua-filter\", filterPath)\n}\n","sourceCodeStart":16,"sourceCodeEnd":42,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/model/pandoc_docx_filter.go#L16-L42","documentation":"writePandocDocxFilter extracts the embedded pandoc_docx_filter.lua (via go:embed) to a working directory before a DOCX export runs, so pandoc can apply SiYuan's Lua filter. The error wraps the os.WriteFile failure, meaning the temp/export directory could not be written to. It is a low-level filesystem failure surfaced during document export, not a pandoc or Lua problem.","triggerScenarios":"Calling the DOCX export path (model/export via pandoc conversion) when the target directory is read-only, was deleted between creation and the WriteFile call, is on a full disk, or the process lacks write permission for the filter file.","commonSituations":"Running the kernel from a read-only volume or with restricted permissions; disk quota/full disk during a large export; antivirus or sandboxing blocking creation of new files in the export dir; exporting to a directory removed by concurrent cleanup.","solutions":["Check that the export directory exists and is writable by the SiYuan process (os.Getuid / permissions on the dir)","Free disk space or raise the quota on the volume holding the export dir","Re-run the export; if the dir was transiently removed, ensure no cleanup job races with export","Run SiYuan outside restricted sandboxes/AV policies that block file creation"],"exampleFix":"// before: assuming export dir is always writable\nfilterPath, err := writePandocDocxFilter(exportDir)\n// after: verify the dir is writable first\nif info, err := os.Stat(exportDir); err != nil || !info.IsDir() {\n    return fmt.Errorf(\"export dir unavailable: %w\", err)\n}\nfilterPath, err := writePandocDocxFilter(exportDir)","handlingStrategy":"try-catch","validationCode":"if info, err := os.Stat(exportDir); err != nil || !info.IsDir() {\n    return fmt.Errorf(\"export dir %s unavailable\", exportDir)\n}\nif f, err := os.CreateTemp(exportDir, \".probe\"); err != nil {\n    return fmt.Errorf(\"export dir %s not writable: %w\", exportDir, err)\n} else { f.Close(); os.Remove(f.Name()) }","typeGuard":null,"tryCatchPattern":"filterPath, err := model.WritePandocDocxFilter(dir)\nif err != nil {\n    var pathErr *os.PathError\n    if errors.As(err, &pathErr) {\n        return fmt.Errorf(\"cannot write filter to %s: %v (check permissions/disk)\", pathErr.Path, pathErr.Err)\n    }\n    return err\n}","preventionTips":["Probe writability of the export directory before starting DOCX export","Monitor disk space on the volume hosting the workspace","Exclude the workspace and temp dirs from AV/sandbox write blocking","Keep SiYuan running with write access to its own workspace"],"tags":["go","filesystem","pandoc","export"],"backgroundTag":"file-write-failed","analyzedSha":"8641553a1f07374001902d3ce773285db1292b2d","analyzedAt":"2026-09-11T16:08:28.414Z","contentChangedAt":"2026-09-11T16:08:28.414Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}