mikefarah/yq · error

unsupported inline table value kind: %v

Error message

unsupported inline table value kind: %v

What it means

mappingToInlineTable builds a TOML inline table and accepts only scalar, sequence and mapping values for each key; any other value kind (typically an AliasNode, since plain nulls are skipped) triggers this error. It fires from inline tables both at top level (writeInlineTableAttribute) and nested inside arrays.

Source

Thrown at pkg/yqlib/encoder_toml.go:455

				continue
			}
			parts = append(parts, fmt.Sprintf("%s = %s", tomlKey(k), te.formatScalar(v)))
		case SequenceNode:
			// inline array in inline table
			arr, err := te.sequenceToInlineArray(v)
			if err != nil {
				return "", err
			}
			parts = append(parts, fmt.Sprintf("%s = %s", tomlKey(k), arr))
		case MappingNode:
			// nested inline table
			inline, err := te.mappingToInlineTable(v)
			if err != nil {
				return "", err
			}
			parts = append(parts, fmt.Sprintf("%s = %s", tomlKey(k), inline))
		default:
			return "", fmt.Errorf("unsupported inline table value kind: %v", v.Kind)
		}
	}
	return "{ " + strings.Join(parts, ", ") + " }", nil
}

func (te *tomlEncoder) writeInlineTableAttribute(w io.Writer, key string, m *CandidateNode) error {
	inline, err := te.mappingToInlineTable(m)
	if err != nil {
		return err
	}
	_, err = w.Write([]byte(tomlKey(key) + " = " + inline + "\n"))
	return err
}

func (te *tomlEncoder) writeTableHeader(w io.Writer, path []string, m *CandidateNode) error {
	// Add blank line before table header (or before comment if present) if we wrote root attributes
	needsBlankLine := te.wroteRootAttr
	if needsBlankLine {

View on GitHub (pinned to 8b5af0694b)

Solutions

  1. Dereference aliases first via JSON round-trip: yq -o json in.yaml | yq -o toml.
  2. Replace the alias/unsupported value with its concrete value in the YAML.
  3. Drop the key (nulls are skipped) or move the value to a position rendered as a regular table.
  4. Patch mappingToInlineTable to resolve AliasNode to its target node.

Example fix

// before
common: &c {a: 1}
tbl: {x: *c}
// after
tbl: {x: {a: 1}}
Defensive patterns

Strategy: type-guard

Validate before calling

yq '.tbl | to_entries | any(.value | kind == "alias" or kind == "null")' in.yaml

Type guard

// Go
func inlineTableSafe(m *yqlib.CandidateNode) bool {
    for i := 1; i < len(m.Content); i += 2 {
        switch m.Content[i].Kind {
        case yqlib.ScalarNode, yqlib.SequenceNode, yqlib.MappingNode:
        default: return false
        }
    }
    return true
}

Try / catch

// Go
if _, err := mappingToInlineTable(m); err != nil {
    if strings.Contains(err.Error(), "unsupported inline table value kind") {
        // resolve alias or drop key, retry
    }
}

Prevention

When it happens

Trigger: Encoding `-o toml` a map value like `k: *alias` or any non-scalar/seq/map node inside a mapping that must be rendered as an inline table (top-level table arrays context or values nested in arrays).

Common situations: YAML anchors used for shared config values converted to TOML; documents where merge keys or aliases appear inside inline-table positions; programmatic tree construction with alias nodes.

Related errors


AI-assisted analysis of mikefarah/yq@8b5af0694b (2026-09-05). Data as JSON: /api/errors/0c3a6b8b52f3ec68. Report an issue: GitHub.