{"record":{"id":"85df4582392d6feb","repo":"vectordotdev/vector","slug":"source-example-has-no-sources-section","errorCode":null,"errorMessage":"Source example has no sources section","messagePattern":"Source example has no sources section","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"vdev/src/commands/check/component_examples.rs","lineNumber":170,"sourceCode":"\nfn wrap_config(\n    kind: &str,\n    component_yaml: YamlValue,\n    component: &Value,\n) -> Result<Option<YamlValue>> {\n    match kind {\n        \"sources\" => wrap_source(&component_yaml, component).map(Some),\n        \"transforms\" => wrap_transform(&component_yaml, component),\n        \"sinks\" => wrap_sink(&component_yaml, component),\n        _ => Ok(Some(component_yaml)),\n    }\n}\n\nfn wrap_source(component_yaml: &YamlValue, component: &Value) -> Result<YamlValue> {\n    let mut root = yaml_mapping(component_yaml, \"source example\")?;\n    let sources = yaml_mapping(\n        mapping_value(&root, \"sources\")\n            .ok_or_else(|| anyhow!(\"Source example has no sources section\"))?,\n        \"source example sources\",\n    )?;\n    let source_key = mapping_key(&sources, \"source example\")?;\n    let mut sinks = Mapping::new();\n\n    let outputs = component.get(\"outputs\").and_then(Value::as_array);\n    let has_named_outputs = outputs\n        .and_then(|outputs| outputs.first())\n        .and_then(|output| output.get(\"name\"))\n        .and_then(Value::as_str)\n        .is_some_and(|name| name != \"<component_id>\");\n    if has_named_outputs {\n        for output in outputs.expect(\"Named outputs require an output list\") {\n            let name = output\n                .get(\"name\")\n                .and_then(Value::as_str)\n                .ok_or_else(|| anyhow!(\"Source output has no name\"))?;\n            sinks.insert(","sourceCodeStart":152,"sourceCodeEnd":188,"githubUrl":"https://github.com/vectordotdev/vector/blob/bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013/vdev/src/commands/check/component_examples.rs#L152-L188","documentation":"Vector's `vdev check component-examples` wraps each component example config to build a validation topology. `wrap_source` expects the example YAML for a source component to have a top-level `sources` section; if that key is absent it cannot identify the source key or wire up validation sinks, so it throws this error.","triggerScenarios":"Running the component example check against an example file whose component YAML lacks a top-level `sources` mapping (e.g. it uses a different root key, nests the component under something else, or the file is not actually a source example).","commonSituations":"A new source was documented with an example YAML that follows a sink/transform template by mistake; the example was hand-edited and `sources:` was removed or renamed; a shared example file was reused for the wrong component type.","solutions":["Add a top-level `sources:` mapping containing the component key to the example YAML.","Verify the example file is registered/selected as a source example, not a transform or sink example.","Confirm YAML indentation places `sources:` at the document root, not nested under another key."],"exampleFix":"// before (example YAML)\ntemplate: my_source\nlog:\n  namespace: x\n\n// after\nsources:\n  my_source:\n    type: my_source\n    log:\n      namespace: x","handlingStrategy":"validation","validationCode":"const root = yaml.parse(exampleYaml);\nif (typeof root !== 'object' || root === null || Array.isArray(root) || !('sources' in root) || typeof root.sources !== 'object' || root.sources === null) {\n  throw new Error('source example must have a top-level `sources` mapping');\n}","typeGuard":"function hasSourcesSection(root) {\n  return typeof root === 'object' && root !== null && !Array.isArray(root) && typeof root.sources === 'object' && root.sources !== null;\n}","tryCatchPattern":null,"preventionTips":["Copy example YAML from an existing source example as a template.","Run `vdev check component-examples` locally before pushing.","Keep `sources:` at the document root with one string-keyed entry."],"tags":["yaml","config-validation","vector"],"backgroundTag":"missing-required-config-field","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"}