{"record":{"id":"033748a9eaf20a39","repo":"siyuan-note/siyuan","slug":"conf-language-0-033748","errorCode":null,"errorMessage":"Conf.Language(0)","messagePattern":"Conf\\.Language\\(0\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/import.go","lineNumber":521,"sourceCode":"\t}\n\tif autoDetect {\n\t\tif importedMetadataErr != nil {\n\t\t\terr = errors.New(Conf.Language(199))\n\t\t\treturn\n\t\t}\n\t\tcreateNotebook = notebookExport\n\t}\n\tif !createNotebook && len(syPaths) < 1 {\n\t\tlogging.LogErrorf(\"invalid .sy.zip without documents [unzipRootPath=%s]\", unzipRootPath)\n\t\terr = errors.New(Conf.Language(199))\n\t\treturn\n\t}\n\tif autoDetect && !createNotebook && boxID == \"\" {\n\t\terr = ErrSYTargetNotebookRequired\n\t\treturn\n\t}\n\tif !createNotebook && nil == Conf.Box(boxID) {\n\t\terr = errors.New(Conf.Language(0))\n\t\treturn\n\t}\n\tif createNotebook {\n\t\tif importedBoxConf != nil && importedBoxConf.Name != \"\" {\n\t\t\tname = importedBoxConf.Name\n\t\t}\n\t\tif !precreatedBox {\n\t\t\tboxID, err = CreateBox(util.RemoveInvalid(name))\n\t\t\tif err != nil {\n\t\t\t\treturn \"\", err\n\t\t\t}\n\t\t}\n\t\tcreatedBoxID = boxID\n\t\tdefer func() {\n\t\t\tif err == nil {\n\t\t\t\treturn\n\t\t\t}\n\t\t\ttreenode.RemoveBlockTreesByBoxID(boxID)","sourceCodeStart":503,"sourceCodeEnd":539,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/import.go#L503-L539","documentation":"importSY0 validates the import target before proceeding. When importing into an existing notebook (auto-detected or explicit boxID, no new notebook creation), it looks up the notebook via Conf.Box(boxID); if no notebook with that ID exists in the workspace, it aborts with the localized error message for language key 0 (typically 'Notebook not found'). This guards against importing a .sy package into a non-existent or unloaded notebook.","triggerScenarios":"Calling ImportSY (or ImportSYNotebookBundle, or the /api/import/* endpoints) without createNotebook set and with a boxID that does not match any notebook in the current workspace, or with autoDetect enabled but no valid notebook detected in the import payload and no boxID supplied (that case raises ErrSYTargetNotebookRequired first; a wrong explicit boxID lands here).","commonSituations":"1) The boxID was copied from another workspace or an old install where the notebook was deleted. 2) The client passes a notebook name instead of its ID. 3) Workspace was switched and the notebook is not present in the new workspace. 4) The notebook exists on disk but is closed or not yet indexed, so it is absent from Conf's in-memory box list.","solutions":["Verify the boxID: GET /api/notebook/lsNotebooks and confirm the target notebook ID exists in the response.","If a new notebook should be created from the package, pass createNotebook=true (and a name) instead of a boxID.","Switch to / open the workspace containing the target notebook, or reopen the closed notebook in the UI so it is loaded.","Correct the calling client so it sends the notebook ID (a 24-character ID), not the notebook title or path."],"exampleFix":"// before\nfetch('/api/import/sy', {body: JSON.stringify({notebook: 'My Notes'})})\n// after\nfetch('/api/import/sy', {body: JSON.stringify({notebook: '20240101120000-abc1234'})}) // valid boxID from lsNotebooks","handlingStrategy":"validation","validationCode":"const boxes = await (await fetch('/api/notebook/lsNotebooks', {method:'POST'})).json();\nif (!boxes.data.notebooks.some(b => b.id === boxID)) {\n  throw new Error(`Notebook ${boxID} does not exist; pick an ID from lsNotebooks`);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always fetch box IDs from /api/notebook/lsNotebooks instead of hard-coding them","Pass createNotebook=true when the package should create its own notebook","Re-fetch the notebook list after switching workspaces before any import","Check for an empty/undefined boxID before calling the import API"],"tags":["notebook","import","validation","siyuan"],"backgroundTag":"resource-not-found","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"}