{"record":{"id":"1b91c63cd52dc76d","repo":"vectordotdev/vector","slug":"expected-description-to-be-a-yaml-mapping","errorCode":null,"errorMessage":"Expected {description} to be a YAML mapping","messagePattern":"Expected (.+?) to be a YAML mapping","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"vdev/src/commands/check/component_examples.rs","lineNumber":381,"sourceCode":"        ),\n        (YamlValue::String(\"inputs\".to_owned()), yaml_list([input])),\n    ]))\n}\n\nfn yaml_list<'a>(values: impl IntoIterator<Item = &'a str>) -> YamlValue {\n    YamlValue::Sequence(\n        values\n            .into_iter()\n            .map(|value| YamlValue::String(value.to_owned()))\n            .collect(),\n    )\n}\n\nfn yaml_mapping(value: &YamlValue, description: &str) -> Result<Mapping> {\n    value\n        .as_mapping()\n        .cloned()\n        .ok_or_else(|| anyhow!(\"Expected {description} to be a YAML mapping\"))\n}\n\nfn mapping_value<'a>(mapping: &'a Mapping, key: &str) -> Option<&'a YamlValue> {\n    mapping.get(YamlValue::String(key.to_owned()))\n}\n\nfn mapping_key(mapping: &Mapping, description: &str) -> Result<String> {\n    mapping\n        .keys()\n        .find_map(YamlValue::as_str)\n        .map(str::to_owned)\n        .ok_or_else(|| anyhow!(\"{description} has no component identifier\"))\n}\n\nfn vector_binary(repo_root: &Path) -> Result<PathBuf> {\n    if let Some(vector_bin) = std::env::var_os(\"VECTOR_BIN\") {\n        return Ok(PathBuf::from(vector_bin));\n    }","sourceCodeStart":363,"sourceCodeEnd":399,"githubUrl":"https://github.com/vectordotdev/vector/blob/bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013/vdev/src/commands/check/component_examples.rs#L363-L399","documentation":"`yaml_mapping` coerces a YAML node to a mapping with a human-readable description of what was expected. If the node is a scalar, sequence, or null instead of a mapping, it throws this error naming the description (e.g. \"source example\", \"sink configuration\").","triggerScenarios":"Any of `wrap_source`, `wrap_transform`, or `wrap_sink` passing a YAML node that is not a mapping: the root document is a list/scalar, the section value is a list, or a component entry under `sources`/`transforms`/`sinks` is a scalar.","commonSituations":"Example YAML uses `- item` list syntax where a mapping is required; the file was truncated or contains only a comment/scalar; a component key was given a value like `true` or a string instead of a config block.","solutions":["Convert the offending YAML node to a mapping (`key: value` pairs) matching the described structure.","If the root document is a list, restructure it into a single mapping with the component-type section at the root.","Give component entries under `sources:`/`transforms:`/`sinks:` full config mappings, not scalars."],"exampleFix":"// before\nsources:\n  - my_source\n\n// after\nsources:\n  my_source:\n    type: my_source","handlingStrategy":"validation","validationCode":"function assertMapping(node, description) {\n  if (node === null || Array.isArray(node) || typeof node !== 'object') {\n    throw new Error(`Expected ${description} to be a YAML mapping`);\n  }\n}","typeGuard":"function isYamlMapping(node) {\n  return typeof node === 'object' && node !== null && !Array.isArray(node);\n}","tryCatchPattern":null,"preventionTips":["Use `key: value` mapping syntax, never list syntax, for component sections.","Parse examples with a YAML tool to inspect the resulting node types (scalars vs mappings)."],"tags":["yaml","type-mismatch","vector"],"backgroundTag":"type-mismatch","analyzedSha":"bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013","analyzedAt":"2026-09-16T02:53:35.741Z","contentChangedAt":"2026-09-16T02:53:35.741Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}