{"record":{"id":"b0cf3508d61df6f6","repo":"siyuan-note/siyuan","slug":"conf-language-180","errorCode":null,"errorMessage":"Conf.Language(180)","messagePattern":"Conf\\.Language\\(180\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/flashcard.go","lineNumber":52,"sourceCode":"\t\"github.com/siyuan-note/filelock\"\n\t\"github.com/siyuan-note/logging\"\n\t\"github.com/siyuan-note/riff\"\n\t\"github.com/siyuan-note/siyuan/kernel/cache\"\n\t\"github.com/siyuan-note/siyuan/kernel/sql\"\n\t\"github.com/siyuan-note/siyuan/kernel/treenode\"\n\t\"github.com/siyuan-note/siyuan/kernel/util\"\n)\n\n// ValidateFlashcardBlockIDs 只允许普通笔记本中可确认存在的块进入全局闪卡存储。\nfunc ValidateFlashcardBlockIDs(blockIDs []string) error {\n\treturn validateFlashcardBlockIDs(blockIDs, treenode.GetBlockTree, IsEncryptedBox)\n}\n\nfunc validateFlashcardBlockIDs(blockIDs []string, getBlockTree func(string) *treenode.BlockTree, isEncryptedBox func(string) bool) error {\n\tfor _, blockID := range blockIDs {\n\t\tbt := getBlockTree(blockID)\n\t\tif bt == nil {\n\t\t\treturn errors.New(Conf.Language(180))\n\t\t}\n\t\tif isEncryptedBox(bt.BoxID) {\n\t\t\treturn errors.New(Conf.Language(393))\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc validateFlashcardTree(rootID string) error {\n\treturn ValidateFlashcardBlockIDs([]string{rootID})\n}\n\nfunc isSupportedFlashcardBlock(blockID string) bool {\n\tbt := treenode.GetBlockTreeInExactBox(blockID, \"\")\n\treturn bt != nil && !IsEncryptedBox(bt.BoxID)\n}\n\nfunc filterSupportedFlashcards(cards []riff.Card) (ret []riff.Card) {","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/flashcard.go#L34-L70","documentation":"validateFlashcardBlockIDs checks each block ID destined for flashcard creation against the block tree; Conf.Language(180) is the localized message 'Search content block does not exist'. It is returned when getBlockTree(blockID) returns nil, i.e. the block ID is unknown to the index, so no flashcard can be made for it.","triggerScenarios":"Calling flashcard APIs (e.g. /api/riff/createDeckWithBlocks, ValidateFlashcardBlockIDs) with a blockID that is not in the block tree — deleted block, wrong ID format that never existed, or index not yet built for new content.","commonSituations":"Client cached an old selection while the block was deleted; passing a static/asset or bookmark anchor string instead of a real block ID; creating cards immediately after import before indexing completes.","solutions":["Verify each blockID exists via the block tree / SQL query (blocks table) before creating cards","Re-index the notebook if blocks were just created and retry","Remove deleted block IDs from the request","Confirm ID format is a 14+ char SiYuan block ID, not a bookmark or tag name"],"exampleFix":"// before\napi.post('/api/riff/createDeckWithBlocks', {deckName, blockIDs: selected})\n// after\nconst rows = await api.post('/api/query/sql', {stmt: `SELECT id FROM blocks WHERE id IN (${ids.map(sqlStr).join(',')})`})\nconst valid = rows.map(r => r.id)\napi.post('/api/riff/createDeckWithBlocks', {deckName, blockIDs: valid})","handlingStrategy":"validation","validationCode":"const existing = new Set((await api.post('/api/query/sql', {stmt: `SELECT id FROM blocks WHERE id IN (${quoted(ids)})`})).data.map(r => r.id))\nconst validIDs = ids.filter(id => existing.has(id))","typeGuard":"const blockExists = (id, known) => known.has(id);","tryCatchPattern":"try { await createDeckWithBlocks(ids) } catch (e) { if (e.msg === L(180)) { await reindex(); const v = ids.filter(blockExists); await retry(v) } }","preventionTips":["Verify block IDs against the blocks SQL table before flashcard APIs","Wait for indexing to complete after bulk imports","Purge selections of blocks deleted via push events"],"tags":["flashcards","block-id","validation","i18n"],"backgroundTag":"entity-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"}