siyuan-note/siyuan · error
invalid AI editor action data
Error message
invalid AI editor action data
What it means
After unmarshalling, loadAIEditorActions validates every stored action: it must be non-nil, its ID must match the SiYuan node-ID pattern (ast.IsNodeIDPattern), and it must have a non-empty Name or Action. Any violation aborts the load with this generic sentinel error. Thrown by GetAIEditorActions, SaveAIEditorAction, and RemoveAIEditorAction.
Solutions
- Open the actions file, locate the offending entry, and fix its ID to a valid node-ID pattern (e.g. 20240101120000-abcdefghijk format) and give it a Name or Action.
- Remove invalid/null entries from the JSON array.
- Prefer re-creating the actions through the SiYuan UI/API so IDs and required fields are generated correctly.
- If unsure which entry is invalid, validate each offline: ast.IsNodeIDPattern(id) plus non-empty (name||action).
Example fix
// before: invalid entry
{"id":"my-action","name":"","action":""}
// after: valid node ID and a non-empty field
{"id":"20240101120000-a1b2c3d4e5f6","name":"Summarize","action":"summarize"} Defensive patterns
Strategy: validation
Validate before calling
const isNodeID = id => /^\d{14}-[0-9a-f]{7}/.test(id); // approximate node-ID pattern
for (const a of data.actions) {
if (a == null || !isNodeID(a.id) || (!a.name && !a.action)) throw new Error('invalid action: ' + JSON.stringify(a));
} Type guard
function isValidAction(a) {
return a != null && typeof a.id === 'string' && /^\d{14}-[0-9a-z]+/.test(a.id) && (a.name || a.action);
} Try / catch
try {
const actions = await fetchSyncPost('/api/ai/editor/getAIEditorActions', {});
} catch (e) {
if (e.message === 'invalid AI editor action data') {
// locate and fix the offending entry in the actions file
}
} Prevention
- Only create actions via the UI/API so IDs and fields are generated correctly
- Validate entries before any scripted import
- Keep IDs in SiYuan node-ID format
- Always set at least one of name/action per entry
When it happens
Trigger: The actions file contains an entry that is null, has an ID not matching the 14-char timestamp-random node ID pattern, or has both empty name and empty action — e.g. after manual editing or a partial write.
Common situations: Hand-editing data/storage JSON and adding an entry with a placeholder ID like "1" or ""; a script bulk-importing actions with missing fields; truncated/corrupted file yielding zero-value entries; copying entries from another app with different ID format.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- createDocTree document contains unknown field
- duplicate AI editor action ID
- each key must be an object
- invalid bazaar index schema
- invalid capability arguments
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/28fcf38c71f5ba77.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/ai_editor.go:175
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
}
func saveAIEditorActions(data *aiEditorActionsData) (err error) {
data.Version = aiEditorActionsVersion
if data.Actions == nil {
data.Actions = []*AIEditorAction{}
}
dirPath := filepath.Dir(aiEditorActionsPath())
if err = os.MkdirAll(dirPath, 0755); err != nil {
return fmt.Errorf("create AI editor actions directory failed: %w", err)View on GitHub (pinned to 9f775e8a12)