siyuan-note/siyuan · error
Query notebook failed
Error message
Query notebook failed
What it means
When importing into an existing notebook (createNotebook=false), importSY0 looks up the target with Conf.Box(boxID); a nil result means no notebook with that ID is configured in the current workspace, and the import fails with the generic Language(0) message 'Query notebook failed'. The real cause - nonexistent target notebook - is only implicit in the message.
Source
Thrown at kernel/model/import.go:285
return
}
if autoDetect {
if importedMetadataErr != nil {
err = errors.New(Conf.Language(199))
return
}
createNotebook = notebookExport
}
if !createNotebook && notebookExport {
err = errors.New(Conf.Language(373))
return
}
if autoDetect && !createNotebook && boxID == "" {
err = ErrSYTargetNotebookRequired
return
}
if !createNotebook && nil == Conf.Box(boxID) {
err = errors.New(Conf.Language(0))
return
}
if createNotebook {
if importedBoxConf != nil && importedBoxConf.Name != "" {
name = importedBoxConf.Name
}
if !precreatedBox {
boxID, err = CreateBox(util.RemoveInvalid(name))
if err != nil {
return "", err
}
}
createdBoxID = boxID
defer func() {
if err == nil {
return
}
treenode.RemoveBlockTreesByBoxID(boxID)View on GitHub (pinned to afa823b6b4)
Solutions
- List the actual notebooks (GET /api/notebook/lsNotebooks) and retry with a valid id
- If the notebook was expected to exist, check that SiYuan is running against the right workspace and that the notebook is not closed/removed
- Create the target notebook first (POST /api/notebook/createNotebook) if it should be new
Defensive patterns
Strategy: validation
Validate before calling
if model.Conf.Box(boxID) == nil {
// refresh notebook list / fail fast before importing
return fmt.Errorf("target notebook %s does not exist", boxID)
}
err := model.ImportSY(zipPath, boxID, toPath) Type guard
func isQueryNotebookFailed(err error) bool {
return err != nil && err.Error() == model.Conf.Language(0)
} Try / catch
if err := model.ImportSY(zipPath, boxID, toPath); err != nil {
if err.Error() == model.Conf.Language(0) {
// re-fetch notebooks via /api/notebook/lsNotebooks and retry with a fresh id
}
} Prevention
- Always resolve the target notebook id at import time, never from a cached value
- Handle notebook-deleted races in long-running clients by re-validating before submit
- Confirm the kernel is pointed at the expected workspace before automated imports
When it happens
Trigger: POST /api/import/importSY (or importSYAuto) whose 'notebook' parameter references a boxID that does not exist right now: deleted before the import ran, never created in this workspace, belongs to a different workspace, or a race with notebook removal.
Common situations: Plugins/automation caching a stale notebook ID from an earlier session. The user deleted the target notebook between choosing it and confirming import. Kernel pointed at a different workspace directory than expected (Settings - About - Workspace).
Related errors
- opened notebook [%s] not found
- invalid import token
- no file found
- import path is not sub path of import dir
- --notebook is required
AI-assisted analysis of siyuan-note/siyuan@afa823b6b4 (2026-08-18).
Data as JSON: /api/errors/271c5e359d1bcb40.
Report an issue: GitHub.