router-for-me/CLIProxyAPI · error

parse plugin priority: %w

Error message

parse plugin priority: %w

What it means

Thrown while decoding the 'priority' field of a plugin instance in config.yaml. The custom PluginInstanceConfig UnmarshalYAML decodes the node under 'priority' into a Go int; on failure it returns this wrapped error. The %w chain exposes the yaml.v3 error, typically 'cannot unmarshal !!str into int' or 'cannot unmarshal !!map into int'.

Source

Thrown at internal/config/config_types.go:73

	}

	for i := 0; i+1 < len(value.Content); i += 2 {
		key := value.Content[i]
		node := value.Content[i+1]
		if key == nil {
			continue
		}
		switch key.Value {
		case "enabled":
			var enabled bool
			if errDecodeEnabled := node.Decode(&enabled); errDecodeEnabled != nil {
				return fmt.Errorf("parse plugin enabled: %w", errDecodeEnabled)
			}
			c.Enabled = &enabled
		case "priority":
			var priority int
			if errDecodePriority := node.Decode(&priority); errDecodePriority != nil {
				return fmt.Errorf("parse plugin priority: %w", errDecodePriority)
			}
			c.Priority = priority
		}
	}

	return nil
}

// MarshalYAML returns the preserved raw plugin YAML subtree for lossless config output.
func (c PluginInstanceConfig) MarshalYAML() (any, error) {
	if c.Raw.Kind == 0 {
		return defaultPluginInstanceConfigNode(), nil
	}
	return deepCopyNode(&c.Raw), nil
}

func defaultPluginInstanceConfigNode() *yaml.Node {
	return &yaml.Node{

View on GitHub (pinned to 78f0c4079e)

Solutions

  1. Set priority to a plain integer in config.yaml, e.g. priority: 10.
  2. Remove quotes and decimal points: change priority: "10" or priority: 1.5 to priority: 10.
  3. Do not use duration or label syntax; priority is an int, not a time or enum.
  4. Re-run the server (or let the config watcher reload) and confirm the error disappears.

Example fix

# before (config.yaml)
plugins:
  configs:
    myplugin:
      priority: "high"

# after
plugins:
  configs:
    myplugin:
      priority: 100
Defensive patterns

Strategy: validation

Validate before calling

#!/bin/sh
# Reject non-integer plugin priorities before starting the server.
if grep -nE 'priority:[[:space:]]*[^0-9-]' config.yaml; then
  echo "plugin priority must be an integer" >&2
  exit 1
fi

Prevention

When it happens

Trigger: A plugins entry with priority set to a non-integer: 'priority: high', 'priority: 1.5', 'priority: "10"' (quoted string), 'priority: 10s' (duration syntax), or a sequence/map under the priority key.

Common situations: Using a descriptive priority label instead of a number; copying example configs that used floats; a hot-reload edit where priority is temporarily a placeholder string; tools templating config with quotes around all values.

Related errors


AI-assisted analysis of router-for-me/CLIProxyAPI@78f0c4079e (2026-08-15). Data as JSON: /api/errors/7df206757bed195d. Report an issue: GitHub.