{"record":{"id":"3b3bfbd81f1a2a84","repo":"nektos/act","slug":"failed-to-insert-node-v-into-mapping-v-unexpecte","errorCode":null,"errorMessage":"failed to insert node %v into mapping %v unexpected type %v expected MappingNode","messagePattern":"failed to insert node (.+?) into mapping (.+?) unexpected type (.+?) expected MappingNode","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/runner/expression.go","lineNumber":298,"sourceCode":"\t\t}\n\t\tk := node.Content[i*2]\n\t\tv := node.Content[i*2+1]\n\t\tev, err := ee.evaluateYamlNodeInternal(ctx, v)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif ev != nil {\n\t\t\tif err := changed(); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t} else {\n\t\t\tev = v\n\t\t}\n\t\tvar sk string\n\t\t// Merge the nested map of the insert directive\n\t\tif k.Decode(&sk) == nil && insertDirective.MatchString(sk) {\n\t\t\tif ev.Kind != yaml.MappingNode {\n\t\t\t\treturn nil, fmt.Errorf(\"failed to insert node %v into mapping %v unexpected type %v expected MappingNode\", ev, node, ev.Kind)\n\t\t\t}\n\t\t\tif err := changed(); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tret.Content = append(ret.Content, ev.Content...)\n\t\t} else {\n\t\t\tek, err := ee.evaluateYamlNodeInternal(ctx, k)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tif ek != nil {\n\t\t\t\tif err := changed(); err != nil {\n\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tek = k\n\t\t\t}\n\t\t\tif ret != nil {","sourceCodeStart":280,"sourceCodeEnd":316,"githubUrl":"https://github.com/nektos/act/blob/4f411281417e88660bea1c1a1749aa71ae0bd60f/pkg/runner/expression.go#L280-L316","documentation":"While recursively evaluating YAML nodes for ${{ }} interpolation (evaluateYamlNodeInternal), when a mapping key matches the insert directive (the 'x: ...' insert-on-key syntax used for matrix includes, i.e. the key matching insertDirective regexp), the corresponding value must itself be a yaml.MappingNode so its content can be merged into the parent mapping. This error fires when the insert directive's value is a scalar or sequence instead of a map.","triggerScenarios":"In a workflow YAML where act evaluates expressions inside mappings (matrix generation with insert keys), writing something like 'insert: value-string' or 'insert: [a, b]' — the key matching the insert directive with a non-mapping value node.","commonSituations":"Hand-editing a matrix strategy block and using act's insert syntax incorrectly; treating an internal act extension syntax as a generic key; version drift where older workflows used the key differently.","solutions":["Find the insert-directive key in your workflow YAML (run act with verbose logging to locate the node) and make its value a mapping (block of key: value pairs), or remove the key entirely.","Use the standard matrix include syntax (strategy.matrix.include as a list) instead of the insert directive if you do not need it.","Re-indent YAML so the value under the directive key parses as a map, not a scalar."],"exampleFix":"# before (workflow yaml)\nmatrix:\n  insert: [1, 2]\n\n# after\nmatrix:\n  os: [ubuntu-latest]\n  insert:\n    os: macos-latest","handlingStrategy":"type-guard","validationCode":"python3 - <<'EOF'\nimport yaml\nfor f in ['.github/workflows/'+x for x in __import__('os').listdir('.github/workflows')]:\n    y=yaml.safe_load(open(f))\n    def walk(n):\n        if isinstance(n,dict):\n            for k,v in n.items():\n                if k=='insert' and not isinstance(v,dict):\n                    raise SystemExit(f'{f}: insert value must be a mapping, got {type(v).__name__}')\n                walk(v)\n        elif isinstance(n,list):\n            for i in n: walk(i)\n    walk(y)\nprint('insert directive ok')\nEOF","typeGuard":"# YAML-level guard: value under an insert key must be a mapping node\nfunc isMappingInsert(v any) bool {\n    m, ok := v.(map[string]any)\n    return ok && len(m) >= 0\n}\n// reject: insert: \"scalar\"  /  insert: [seq]","tryCatchPattern":null,"preventionTips":["Treat the insert directive as advanced syntax; prefer standard matrix.include.","Run act --verbose on a tiny workflow when matrix interpolation fails, to locate the node.","Indent insert values as a block map."],"tags":["yaml","matrix","expression","act"],"backgroundTag":null,"analyzedSha":"4f411281417e88660bea1c1a1749aa71ae0bd60f","analyzedAt":"2026-08-15T09:19:46.307Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}