{"record":{"id":"a3f3c6b5beaecc1b","repo":"vectordotdev/vector","slug":"all-of-subschemas-must-be-present-here","errorCode":null,"errorMessage":"all-of subschemas must be present here","messagePattern":"all-of subschemas must be present here","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/vector-config/src/schema/helpers.rs","lineNumber":388,"sourceCode":"                };\n\n                schema = wrapped_schema;\n            }\n            Some(subschemas) => {\n                if let Some(any_of) = subschemas.any_of.as_mut() {\n                    // A null schema is just another possible variant, so we add it directly.\n                    any_of.push(Schema::Object(generate_null_schema()));\n                } else if let Some(one_of) = subschemas.one_of.as_mut() {\n                    // A null schema is just another possible variant, so we add it directly.\n                    one_of.push(Schema::Object(generate_null_schema()));\n                } else if subschemas.all_of.is_some() {\n                    // If we're dealing with an all-of schema, we have to build a new one-of schema\n                    // where the two choices are either the `null` schema, or a subschema comprised of\n                    // the all-of subschemas.\n                    let all_of = subschemas\n                        .all_of\n                        .take()\n                        .expect(\"all-of subschemas must be present here\");\n                    let new_all_of_schema = SchemaObject {\n                        subschemas: Some(Box::new(SubschemaValidation {\n                            all_of: Some(all_of),\n                            ..Default::default()\n                        })),\n                        ..Default::default()\n                    };\n\n                    subschemas.one_of = Some(vec![\n                        Schema::Object(generate_null_schema()),\n                        Schema::Object(new_all_of_schema),\n                    ]);\n                } else {\n                    return Err(GenerateError::InvalidOptionalSchema);\n                }\n            }\n        },\n        Some(sov) => match sov {","sourceCodeStart":370,"sourceCodeEnd":406,"githubUrl":"https://github.com/vectordotdev/vector/blob/bdb87aeaa4c4ff27c0ba643c1c77b21bf2ef4013/lib/vector-config/src/schema/helpers.rs#L370-L406","documentation":"In `generate_optional_schema`, the code converts an all-of subschema into a one-of {null, all-of} schema to make a type optional. The `is_some()` check and the `.take()` on `subschemas.all_of` are expected to agree; the panic fires if the all-of field is somehow absent despite the earlier branch check, i.e. an internal invariant of the schema generator was violated.","triggerScenarios":"Calling `generate_optional_schema` on a `SubschemaValidation` where the `all_of` field is `None` while the branch condition claimed it was `Some`, typically due to a bug in a custom `Configurable::generate_schema` implementation or a mismatched schemars version that mutates subschemas between the check and the take.","commonSituations":"Upgrading the `schemars` crate so that `SubschemaValidation` semantics changed; a hand-written `generate_schema` for a custom type returning a malformed subschema object; concurrent mutation of the schema during generation.","solutions":["Verify the schemars version matches the one vector-config was built against (check Cargo.lock) and re-pin","Audit any custom `Configurable::generate_schema` implementations that build subschemas manually and ensure all_of is fully populated","Rebuild the schema generation for the offending component config and reproduce with `cargo vdev` to get a stack trace","File/inspect an issue on vector-config if reproducible with stock types"],"exampleFix":"// before (custom generate_schema)\nOk(SchemaObject { metadata: None, instance_type: None, ..Default::default() })\n// after\nOk(SchemaObject {\n    subschemas: Some(Box::new(SubschemaValidation {\n        all_of: Some(vec![schema]),\n        ..Default::default()\n    })),\n    ..Default::default()\n})","handlingStrategy":"validation","validationCode":"fn validate_subschemas(s: &SchemaObject) -> Result<(), String> {\n    if let Some(sub) = &s.subschemas {\n        if sub.all_of.is_none() && sub.any_of.is_none() && sub.one_of.is_none() {\n            return Err(\"subschema object present but has no all_of/any_of/one_of\".into());\n        }\n    }\n    Ok(())\n}","typeGuard":"fn has_all_of(sub: &SubschemaValidation) -> bool { sub.all_of.is_some() }","tryCatchPattern":"let all_of = match subschemas.all_of.take() {\n    Some(v) => v,\n    None => return Err(GenerateError::InvalidOptionalSchema),\n};","preventionTips":["Keep schemars pinned to the version vector-config was tested against","Validate custom generate_schema outputs against the expected subschema shape in unit tests","Never mutate schema subschemas between the eligibility check and use"],"tags":["rust","schema-generation","internal-invariant"],"backgroundTag":"internal-invariant-violation","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"}