siyuan-note/siyuan · error
export failed: empty artifact path
Error message
export failed: empty artifact path
What it means
materializeExportArtifact is the post-export step that takes the artifact path produced by the kernel export routine and secures it via an export-artifact lease before copying it to the requested output. If the export path comes back empty it means the underlying export produced no file, so it returns this error instead of leasing a nonexistent path.
Solutions
- Check that the document ID exists in the workspace and its .sy file is readable before exporting.
- Log/inspect the return value of the underlying model export call; fix the upstream export to return a real path.
- If this is a test, pass a non-empty fixture path (the empty-path rejection is intentional).
- Retry after restarting the kernel / re-indexing if the export subsystem returned empty due to transient state.
Example fix
// before
path, _ := model.ExportDocHTML(id)
result, err := materializeExportArtifact(path, output) // panics into empty-path error
// after
path, err := model.ExportDocHTML(id)
if err != nil {
return err
}
if path == "" {
return fmt.Errorf("export produced no artifact for id %s", id)
}
result, err := materializeExportArtifact(path, output) Defensive patterns
Strategy: try-catch
Validate before calling
path, err := model.ExportDocHTML(id)
if err != nil {
return fmt.Errorf("upstream export for %s failed: %w", id, err)
}
if path == "" {
return fmt.Errorf("export for %s produced no artifact", id)
}
return materializeExportArtifact(path, output) Try / catch
result, err := materializeExportArtifact(path, output)
if err != nil {
if strings.Contains(err.Error(), "empty artifact path") {
// upstream export returned no path; re-export or report id
}
return err
} Prevention
- Never discard the error from the underlying export call
- Assert non-empty artifact path before leasing
- Verify the document exists in the workspace before exporting
- Keep tests using intentional empty-path cases only for the rejection path
When it happens
Trigger: The kernel export call (model export for html/preview/docx/sy/md-zip) returns success but with an empty exportPath — e.g. the document failed to render or the export API silently produced nothing — and materializeExportArtifact is then invoked with exportPath="".
Common situations: Exporting a document whose tree is missing/corrupted in the workspace; calling this helper from tests with an empty path (see TestMaterializeExportArtifactRejectsEmptyPath); a kernel API change that stopped returning the artifact path.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- export failed: empty content
- --id is required
- --output is required for docx
- appearance files not found at
- asset path is required
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/7a30d1038362de89.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/cli/cmd/export.go:223
zipPath, err := model.ExportData()
if err != nil {
return err
}
resultPath, err := materializeExportArtifact(zipPath, output)
if err != nil {
return err
}
if output == "" {
fmt.Println(resultPath)
}
return nil
},
}
func materializeExportArtifact(exportPath, output string) (resultPath string, err error) {
if exportPath == "" {
return "", fmt.Errorf("export failed: empty artifact path")
}
lease, err := model.AcquireExportArtifactLease(exportPath)
if err != nil {
return "", err
}
defer model.ReleaseExportArtifactLease(lease.ID)
if output == "" {
return lease.Path, nil
}
if err = filelock.Copy(lease.Path, output); err != nil {
return "", err
}
return output, nil
}
func init() {
exportMdCmd.Flags().String("id", "", "block ID")View on GitHub (pinned to 9f775e8a12)