{"record":{"id":"3ab77ff71d24832d","repo":"vectordotdev/vector","slug":"schema-definition-must-exist-unevaluated","errorCode":null,"errorMessage":"schema definition must exist","messagePattern":"schema definition must exist","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/vector-config/src/schema/visitors/unevaluated.rs","lineNumber":79,"sourceCode":"        //\n        // When a given schema reference (the actual target of `$ref`) is eligible for flattening in\n        // a given schema (what we're currently visiting) then it means that this schema would,\n        // based on its composition, lead to the schema reference either being marked or unmarked.\n        //\n        // We flatten the schema reference into this schema to avoid that from occurring, and we do\n        // so based on whichever group of referrers -- the schemas which reference the particular\n        // target schema -- is smaller, such that we do the minimum number of flattenings per target\n        // schema, to keep the schema as small as we reasonably can.\n        if let Some(reference) = schema.reference.as_ref() {\n            let current_parent_schema_ref = self.get_current_schema_scope();\n\n            if let Some(referrers) = self.eligible_to_flatten.get(reference)\n                && referrers.contains(current_parent_schema_ref)\n            {\n                let current_schema_ref = get_cleaned_schema_reference(reference);\n                let referenced_schema = definitions\n                    .get(current_schema_ref)\n                    .expect(\"schema definition must exist\");\n\n                debug!(\n                    referent = current_schema_ref,\n                    referrer = current_parent_schema_ref.as_ref(),\n                    \"Found eligible referent/referrer mapping.\"\n                );\n\n                if let Schema::Object(referenced_schema) = referenced_schema {\n                    debug!(\n                        referent = current_schema_ref,\n                        referrer = current_parent_schema_ref.as_ref(),\n                        \"Flattening referent into referrer.\"\n                    );\n\n                    schema.reference = None;\n                    schema.merge(referenced_schema);\n                }\n            }","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/vectordotdev/vector/blob/bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013/lib/vector-config/src/schema/visitors/unevaluated.rs#L61-L97","documentation":"The unevaluated-properties flattening visitor looks up each eligible `$ref` in the definitions map and asserts the definition exists before inlining it into referrer schemas. The panic fires when an entry in `eligible_to_flatten` has no corresponding definition — the set and the definitions map are out of sync.","triggerScenarios":"`visit_schema_object` processes a reference classified as eligible to flatten, but `definitions` no longer contains it because another visitor removed it or the eligibility analysis ran against a different root schema.","commonSituations":"Running the flatten visitor after a definition-pruning visitor; reusing a visitor instance (with cached eligibility sets) across multiple root schemas; version skew between vector-config crates.","solutions":["Construct a fresh visitor per root schema so the eligible set matches the definitions","Order definition-removing visitors after the unevaluated-flattening visitor","Verify all workspace crates resolve to one consistent vector-config version","Reproduce with the offending component config and inspect the eligibility map vs definitions"],"exampleFix":"// before (shared visitor across schemas)\nlet mut visitor = DisallowUnevaluatedPropertiesVisitor::default();\nfor schema in schemas { visitor.visit_root_schema(schema); }\n// after\nfor schema in schemas {\n    DisallowUnevaluatedPropertiesVisitor::default().visit_root_schema(schema);\n}","handlingStrategy":"validation","validationCode":"fn eligible_refs_present(eligible: &HashMap<String, Vec<String>>, defs: &Map<String, Schema>) -> Result<(), String> {\n    for name in eligible.keys() {\n        if !defs.contains_key(name.as_str()) {\n            return Err(format!(\"eligible-to-flatten ref missing: {name}\"));\n        }\n    }\n    Ok(())\n}","typeGuard":null,"tryCatchPattern":"let referenced = definitions.get(current_schema_ref).ok_or_else(||\n    anyhow::anyhow!(\"flatten target {current_schema_ref} missing from definitions\"))?;","preventionTips":["Create a fresh visitor per root schema; do not reuse cached eligibility maps","Run flattening before any visitor that prunes definitions","Add integration tests covering unevaluatedProperties across component configs"],"tags":["rust","schema-generation","json-schema"],"backgroundTag":"resource-not-found","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"}