siyuan-note/siyuan · error

unsupported AI editor actions version

Error message

unsupported AI editor actions version [%d]

What it means

loadAIEditorActions enforces that the stored aiEditorActionsData.Version equals the current aiEditorActionsVersion constant. When the on-disk file was written by a different (older or newer) format version, this error is returned to GetAIEditorActions/SaveAIEditorAction/RemoveAIEditorAction. There is no downgrade/upgrade migration for arbitrary versions.

Solutions

  1. Check the reported version in the message against the kernel's aiEditorActionsVersion constant in kernel/model/ai_editor.go.
  2. Upgrade SiYuan to the version that wrote the file (if file version is newer) rather than editing the file.
  3. For an older version, migrate manually: back up the file, adjust the version field to the current constant, and ensure actions entries satisfy validation.
  4. If the data is disposable, delete the actions file so it is recreated empty; otherwise hand-port actions via the AI editor UI into a fresh file.

Example fix

// before: stale version in data file
{"version":0,"actions":[...]}
// after: match aiEditorActionsVersion
{"version":1,"actions":[...]}
Defensive patterns

Strategy: fallback

Validate before calling

// pre-check stored version
codec: const data = JSON.parse(fs.readFileSync(actionsPath,'utf8'));
if (data.version !== CURRENT_AI_EDITOR_ACTIONS_VERSION) console.warn('version mismatch:', data.version);

Try / catch

try {
  const actions = await fetchSyncPost('/api/ai/editor/getAIEditorActions', {});
} catch (e) {
  if (/unsupported AI editor actions version/.test(e.message)) {
    // upgrade the kernel to the version that wrote the file, or migrate/restore backup
  }
}

Prevention

When it happens

Trigger: The actions file in the workspace contains a version field different from aiEditorActionsVersion — typically a file created by a newer SiYuan build then opened by an older kernel, or a hand-edited file with a wrong version value.

Common situations: Downgrading SiYuan after using a newer format; copying a data directory between machines with different SiYuan versions; manually editing the JSON and mistyping the version number; restoring an old backup whose format predates the current constant.

Related errors


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

Appendix: source

Thrown at kernel/model/ai_editor.go:166

func loadAIEditorActions() (ret *aiEditorActionsData, err error) {
	ret = &aiEditorActionsData{
		Version: aiEditorActionsVersion,
		Actions: []*AIEditorAction{},
	}
	dataPath := aiEditorActionsPath()
	if !filelock.IsExist(dataPath) {
		return ret, nil
	}

	data, err := filelock.ReadFile(dataPath)
	if err != nil {
		return nil, fmt.Errorf("read AI editor actions failed: %w", err)
	}
	if err = gulu.JSON.UnmarshalJSON(data, ret); err != nil {
		return nil, fmt.Errorf("unmarshal AI editor actions failed: %w", err)
	}
	if ret.Version != aiEditorActionsVersion {
		return nil, fmt.Errorf("unsupported AI editor actions version [%d]", ret.Version)
	}
	if ret.Actions == nil {
		ret.Actions = []*AIEditorAction{}
	}

	ids := make(map[string]struct{}, len(ret.Actions))
	for _, action := range ret.Actions {
		if action == nil || !ast.IsNodeIDPattern(action.ID) || (action.Name == "" && action.Action == "") {
			return nil, errors.New("invalid AI editor action data")
		}
		if _, ok := ids[action.ID]; ok {
			return nil, fmt.Errorf("duplicate AI editor action ID [%s]", action.ID)
		}
		ids[action.ID] = struct{}{}
	}
	return ret, nil
}

View on GitHub (pinned to 9f775e8a12)