siyuan-note/siyuan · error

unsupported template operation

Error message

unsupported template operation

What it means

ManageTemplateFiles supports a fixed set of actions (list, create, read, write, move, remove, etc.); any other action value falls through to the switch default and returns this error. It is a simple operation-enum guard so unknown or misspelled actions fail fast instead of silently doing nothing.

Source

Thrown at kernel/model/template_manage.go:321

			return nil, errors.New("template source must use the .md extension")
		}
		if _, err = root.Stat(request.Target); !errors.Is(err, os.ErrNotExist) {
			return nil, errors.New("template destination already exists or is inaccessible")
		}
		return nil, root.Rename(request.Path, request.Target)
	case "remove":
		// 将整个目录连同包资源移入隐藏恢复目录,保留误删后的恢复材料。
		trash := ".trash/" + ast.NewNodeID()
		if err = root.MkdirAll(trash, 0700); err != nil {
			return nil, err
		}
		target := path.Join(trash, path.Base(request.Path))
		if err = root.Rename(request.Path, target); err != nil {
			return nil, err
		}
		return map[string]string{"recoveryPath": target}, nil
	default:
		return nil, errors.New("unsupported template operation")
	}
}

View on GitHub (pinned to 8641553a1f)

Solutions

  1. Use one of the supported action strings exactly (e.g. "list", "create", "read", "write", "move", "remove")
  2. If you meant deletion, use action="remove" instead of "delete"
  3. Check the API definition for TemplateFileRequest.Action in the current kernel version to see the valid enum

Example fix

// before
{ "action": "delete", "path": "/old.md" }
// after
{ "action": "remove", "path": "/old.md" }
Defensive patterns

Strategy: validation

Validate before calling

const ALLOWED = ['list','create','read','write','move','remove'];
if (!ALLOWED.includes(request.action)) {
  throw new Error('unsupported action: ' + request.action);
}

Type guard

const isValidAction = (a) =>
  typeof a === 'string' && ['list','create','read','write','move','remove'].includes(a);

Try / catch

try {
  return await fetchPost('/api/template/manageTemplateFiles', request);
} catch (e) {
  if (String(e.message).includes('unsupported template operation')) {
    console.error('Bad action, valid values: list|create|read|write|move|remove', request.action);
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling the kernel's manageTemplateFiles API (HTTP /api/template/manageTemplateFiles) with a request.Action that is not one of the supported verbs — typo (e.g. 'delete' instead of 'remove'), missing action, or a plugin using an action from a newer/older API version.

Common situations: Plugin code written against a different API version using an action that no longer exists; hand-crafted HTTP calls with 'delete'/'rm'/'copy' guesses; empty action field because the payload was mis-built.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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