siyuan-note/siyuan · error

notebook configuration is missing

Error message

notebook configuration is missing

What it means

prepareBoxConfForSave rejects a save when the caller passes a nil notebook configuration pointer. SiYuan cannot build a persisted copy of a conf that does not exist, so it fails fast before touching the runtime normal-box registry or disk. This is a defensive argument check at the entry of the save path invoked by SaveConf.

Solutions

  1. Ensure the BoxConf exists (Conf.GetBox(boxID) or equivalent) before calling SaveConf; create it if missing
  2. Check for nil before saving and skip or return a friendly message instead of invoking the save path
  3. Trace where the nil conf came from — typically a lookup failure for boxID that was ignored upstream

Example fix

// before
conf.SaveConf(boxID, nil)
// after
if box := Conf.GetBox(boxID); box != nil {
    conf.SaveConf(boxID, box.Conf)
}
Defensive patterns

Strategy: validation

Validate before calling

if boxConf == nil {
    return fmt.Errorf("notebook %s has no configuration to save", boxID)
}

Type guard

func boxConfReady(bc *conf.BoxConf) bool { return bc != nil }

Try / catch

persisted, err := prepareBoxConfForSave(boxID, boxConf)
if err != nil {
    // nil conf: load or create the BoxConf and retry once
}

Prevention

When it happens

Trigger: SaveConf (or any caller of prepareBoxConfForSave) passes boxID with a nil *conf.BoxConf, e.g. a nil entry in a conf map or a failed lookup being saved unconditionally.

Common situations: Programmatic API/plugin code calling the notebook-save endpoint with a missing or null conf object; a race where the notebook was closed/removed between lookup and save; code constructing BoxConf lazily and forgetting to allocate it.

Related errors


AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19). Data as JSON: /api/errors/20b95e6159167ae1. Report an issue: GitHub.

Appendix: source

Thrown at kernel/model/box_conf_crypto.go:90

}

func revealBoxMetadataIfUnlocked(boxID string, boxConf *conf.BoxConf) error {
	clearBoxMetadata(boxConf)
	dek, ok := cachedDEKCopy(boxID)
	if !ok {
		return nil
	}
	defer zeroAndClear(dek)
	if err := decryptBoxMetadata(boxID, boxConf, dek); err != nil {
		setEncryptedBoxState(boxID, EncryptedBoxStateError)
		return err
	}
	return nil
}

func prepareBoxConfForSave(boxID string, boxConf *conf.BoxConf) (*conf.BoxConf, error) {
	if boxConf == nil {
		return nil, errors.New("notebook configuration is missing")
	}
	persisted := *boxConf
	persisted.BoxCrypt = DeepCopyBoxEncryption(boxConf.BoxCrypt)
	if persisted.Encrypted {
		forgetRuntimeNormalBox(boxID)
	}
	if !persisted.Encrypted {
		if IsEncryptedBox(boxID) {
			return nil, errors.New("encrypted notebook cannot be saved as a normal notebook")
		}
		return &persisted, nil
	}
	if persisted.BoxCrypt == nil {
		clearBoxMetadata(&persisted)
		return &persisted, nil
	}
	if GetEncryptedBoxState(boxID) == EncryptedBoxStateError {
		return nil, errors.New("encrypted notebook is in an error state")

View on GitHub (pinned to 9f775e8a12)