{"record":{"id":"3a52332a2834b2fc","repo":"siyuan-note/siyuan","slug":"export-source-s-is-not-a-regular-file","errorCode":null,"errorMessage":"export source [%s] is not a regular file","messagePattern":"export source \\[(.+?)\\] is not a regular file","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/api/export.go","lineNumber":1202,"sourceCode":"\n\tif err := copyExportFileToDestination(srcFullPath, dest); err != nil {\n\t\tlogging.LogErrorf(\"copy export file [%s] to [%s] failed: %s\", srcFullPath, dest, err)\n\t\tret.Code = -1\n\t\tret.Msg = err.Error()\n\t\treturn\n\t}\n}\n\nfunc copyExportFileToDestination(src, dest string) (err error) {\n\tfilelock.Lock(src)\n\tdefer filelock.Unlock(src)\n\n\tsrcInfo, err := os.Lstat(src)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif !srcInfo.Mode().IsRegular() {\n\t\treturn fmt.Errorf(\"export source [%s] is not a regular file\", src)\n\t}\n\n\tsrcFile, err := os.Open(src)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer srcFile.Close()\n\n\tdestDir := filepath.Dir(dest)\n\tif err = os.MkdirAll(destDir, 0755); err != nil {\n\t\treturn err\n\t}\n\ttmpFile, err := os.CreateTemp(destDir, \".siyuan-export-*.tmp\")\n\tif err != nil {\n\t\treturn err\n\t}\n\ttmpPath := tmpFile.Name()\n\ttmpClosed := false","sourceCodeStart":1184,"sourceCodeEnd":1220,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/api/export.go#L1184-L1220","documentation":"Returned by copyExportFileToDestination (export.go:1201) when the export source path does not resolve to a regular file (os.Lstat shows it is a directory, symlink target, device, socket, etc.). The export copy logic only reads plain files; anything else — a missing file, a directory, a dangling symlink, a FIFO — is refused before opening to avoid hanging on special files or copying unintended content.","triggerScenarios":"The export-to-disk endpoint (the one calling copyExportFileToDestination at export.go:1185) is invoked with a `srcFullPath` that Lstat's as non-regular: the temp export artifact was deleted/moved before copy, the path points at a directory, or a symlink resolves to a special file. A preceding export step failed to produce the expected rendered PDF/HTML/zip file.","commonSituations":"Concurrent cleanup or temp-dir eviction (e.g. another export, a crash, or a cleanup job) removing the staged export artifact between render and copy. Misconfigured export path pointing at a folder. Disk-full or permission error during staging that left a partial/zero-byte non-file entry. OS-level symlink inside the temp dir.","solutions":["Verify the export source exists and is a regular file right before the copy step (os.Stat / check Mode().IsRegular()).","Retry the full export operation (re-render) so the staging artifact is regenerated cleanly.","Ensure no other process is clearing util.TempDir/export during export, and that the workspace temp dir has adequate free space and permissions.","If the user-supplied destination triggered a path issue, confirm `dest` resolves under the intended directory and is not itself a directory."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Verify source is a regular file before invoking export copy\ninfo, err := os.Lstat(src)\nif err != nil || !info.Mode().IsRegular() {\n  return fmt.Errorf(\"export source missing or not a regular file: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"try { await exportTo(dest); }\ncatch (e) {\n  if (/not a regular file/.test(e.msg)) { await reRunExport(); /* retry with fresh artifact */ }\n  else throw e;\n}","preventionTips":["Ensure util.TempDir has adequate free space and is not cleaned concurrently during export.","Run export in isolation to avoid staged-artifact races.","Validate the staged artifact exists immediately before the copy step."],"tags":["export","filesystem","kernel"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}