siyuan-note/siyuan · error

Conf.Language(313)

Error message

Conf.Language(313)

What it means

validateFlashcardBlockIDs reports, through the localized message Conf.Language(313), that the block belongs to an encrypted notebook (isEncryptedBox). Encrypted notebooks are excluded from flashcard operations because their data cannot be processed by the RIFF scheduler index in plaintext.

Solutions

  1. Use flashcards only for blocks in unencrypted notebooks; move the block content to a normal notebook if flashcards are required.
  2. Filter candidate block IDs by notebook before calling the API (check the notebook's encryption status via the notebook list API).
  3. Do not attempt to bypass the check — encrypted-notebook data must remain authenticated and unprocessed by non-supporting features.

Example fix

// before
await addRiffCards(blockIDs)
// after
const enc = await getEncryptedNotebookIDs()
const ok = blockIDs.filter(id => !enc.has(blockToBox[id]))
await addRiffCards(ok)
Defensive patterns

Strategy: validation

Validate before calling

const notebooks = await fetchPost('/api/notebook/lsNotebooks', {})
const encrypted = new Set(notebooks.filter(nb => nb.closed === false && nb.isEncrypted).map(nb => nb.id))
const usable = blockIDs.filter(id => !encrypted.has(blockToBox(id)))

Try / catch

try {
  await addRiffCards(ids)
} catch (e) {
  if (String(e.msg).includes(Lang313)) showMsg('Flashcards are not supported for encrypted notebooks', 'error')
  else throw e
}

Prevention

When it happens

Trigger: Calling ValidateFlashcardBlockIDs with a blockID whose bt.BoxID refers to a notebook encrypted by the kernel's encrypted-notebook feature; any flashcard create/remove/reset call that validates such block IDs.

Common situations: A user with a mix of encrypted and normal notebooks selects blocks from an encrypted notebook; a plugin enumerates all blocks across notebooks without filtering out encrypted ones; scripts written before encrypted notebooks were introduced.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of siyuan-note/siyuan@8641553a1f (2026-09-11). Data as JSON: /api/errors/1674a3d9e68d3116. Report an issue: GitHub.

Appendix: source

Thrown at kernel/model/flashcard.go:55

	"github.com/siyuan-note/siyuan/kernel/cache"
	"github.com/siyuan-note/siyuan/kernel/sql"
	"github.com/siyuan-note/siyuan/kernel/treenode"
	"github.com/siyuan-note/siyuan/kernel/util"
)

// ValidateFlashcardBlockIDs 只允许普通笔记本中可确认存在的块进入全局闪卡存储。
func ValidateFlashcardBlockIDs(blockIDs []string) error {
	return validateFlashcardBlockIDs(blockIDs, treenode.GetBlockTree, IsEncryptedBox)
}

func validateFlashcardBlockIDs(blockIDs []string, getBlockTree func(string) *treenode.BlockTree, isEncryptedBox func(string) bool) error {
	for _, blockID := range blockIDs {
		bt := getBlockTree(blockID)
		if bt == nil {
			return errors.New(Conf.Language(180))
		}
		if isEncryptedBox(bt.BoxID) {
			return errors.New(Conf.Language(313))
		}
	}
	return nil
}

func validateFlashcardTree(rootID string) error {
	return ValidateFlashcardBlockIDs([]string{rootID})
}

func isSupportedFlashcardBlock(blockID string) bool {
	bt := treenode.GetBlockTreeInExactBox(blockID, "")
	return bt != nil && !IsEncryptedBox(bt.BoxID)
}

func filterSupportedFlashcards(cards []riff.Card) (ret []riff.Card) {
	for _, card := range cards {
		if card == nil || !isSupportedFlashcardBlock(card.BlockID()) {
			continue

View on GitHub (pinned to 8641553a1f)