nektos/act · error

%sFailed to match %s: %w

Error message

%sFailed to match %s: %w

What it means

Error from Node.checkOneOf (schema.go:321): the node failed to validate against every alternative in the schema's OneOf list; each alternative's failure is joined as 'Failed to match <type>: <err>'. Returned when no alternative matched, i.e. union-type resolution failed.

Source

Thrown at pkg/schema/schema.go:321

		}
	}
	return nil
}

func (s *Node) checkOneOf(def Definition, node *yaml.Node) error {
	var allErrors error
	for _, v := range *def.OneOf {
		sub := &Node{
			Definition: v,
			Schema:     s.Schema,
			Context:    append(append([]string{}, s.Context...), s.Schema.GetDefinition(v).Context...),
		}

		err := sub.UnmarshalYAML(node)
		if err == nil {
			return nil
		}
		allErrors = errors.Join(allErrors, fmt.Errorf("%sFailed to match %s: %w", formatLocation(node), v, err))
	}
	return allErrors
}

func getStringKind(k yaml.Kind) string {
	switch k {
	case yaml.DocumentNode:
		return "document"
	case yaml.SequenceNode:
		return "sequence"
	case yaml.MappingNode:
		return "mapping"
	case yaml.ScalarNode:
		return "scalar"
	case yaml.AliasNode:
		return "alias"
	default:
		return "unknown"

View on GitHub (pinned to 4f41128141)

Solutions

  1. Read each 'Failed to match <alt>' branch — the alt that is closest to your intent shows what shape it wanted
  2. Restructure the YAML value to one of the declared alternative shapes
  3. Quote strings that YAML might coerce (on/off/true/yes) to avoid accidental type changes

Example fix

# before (expects string or list-of-string, got mapping):
needs:
  build: true
# after:
needs: build
# or
needs: [build, test]
Defensive patterns

Strategy: validation

Validate before calling

# For polymorphic fields, pre-check your value matches at least one documented shape (string OR list OR map) per the GitHub schema

Try / catch

Inspect every 'Failed to match <alt>' branch, pick the intended alternative, reshape the value accordingly.

Prevention

When it happens

Trigger: A value that fits none of the declared alternatives, e.g. a field that accepts either a string or a sequence of strings receiving a mapping. Each sub-Node is validated with merged Context; the first success returns nil, otherwise all errors accumulate.

Common situations: GitHub schema fields with polymorphic shapes (string | list | object) getting a wrong-shape value; indentation or YAML type coercion (`on:`, `true` → bool) producing unexpected node kinds.

Related errors


AI-assisted analysis of nektos/act@4f41128141 (2026-08-15). Data as JSON: /api/errors/babcc1ca3c167501. Report an issue: GitHub.