nektos/act · error

%sExpected a mapping got %v

Error message

%sExpected a mapping got %v

What it means

Type error from Node.checkMapping (schema.go:364): the definition declares a Mapping but the YAML node is not yaml.MappingNode (e.g. a scalar or sequence appears where a key/value block is required).

Source

Thrown at pkg/schema/schema.go:364

	}
	var allErrors error
	for _, v := range node.Content {
		allErrors = errors.Join(allErrors, (&Node{
			Definition: def.Sequence.ItemType,
			Schema:     s.Schema,
			Context:    append(append([]string{}, s.Context...), s.Schema.GetDefinition(def.Sequence.ItemType).Context...),
		}).UnmarshalYAML(v))
	}
	return allErrors
}

func formatLocation(node *yaml.Node) string {
	return fmt.Sprintf("Line: %v Column %v: ", node.Line, node.Column)
}

func (s *Node) checkMapping(node *yaml.Node, def Definition) error {
	if node.Kind != yaml.MappingNode {
		return fmt.Errorf("%sExpected a mapping got %v", formatLocation(node), getStringKind(node.Kind))
	}
	insertDirective := regexp.MustCompile(`\${{\s*insert\s*}}`)
	var allErrors error
	for i, k := range node.Content {
		if i%2 == 0 {
			if insertDirective.MatchString(k.Value) {
				if len(s.Context) == 0 {
					allErrors = errors.Join(allErrors, fmt.Errorf("%sinsert is not allowed here", formatLocation(k)))
				}
				continue
			}

			isExpr, err := s.checkExpression(k)
			if err != nil {
				allErrors = errors.Join(allErrors, err)
				continue
			}
			if isExpr {

View on GitHub (pinned to 4f41128141)

Solutions

  1. Rewrite the value as key: value pairs under the field
  2. Check indentation — mapping children must be indented consistently under their key

Example fix

# before:
with: docker://alpine:3.19
# after:
with:
  entrypoint: /bin/sh
  args: -c 'echo hi'
Defensive patterns

Strategy: type-guard

Validate before calling

# Mapping-typed fields (with:, env:, secrets:) must contain key: value pairs, indented under the key

Type guard

func isMapping(n *yaml.Node) bool { return n.Kind == yaml.MappingNode }

Try / catch

Fatal validation error — rewrite the value as a key/value block.

Prevention

When it happens

Trigger: Putting a plain scalar or a list under a mapping-typed field, e.g. `with: docker://alpine` instead of key: value pairs, or `env: [A, B]` instead of a map.

Common situations: Missing key names in `with:`/`env:` blocks; collapsing a block mapping onto one line incorrectly; YAML flow syntax mistakes.

Related errors


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