vectordotdev/vector · error
all-of subschemas must be present here
Error message
all-of subschemas must be present here
What it means
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.
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
Example fix
// before (custom generate_schema)
Ok(SchemaObject { metadata: None, instance_type: None, ..Default::default() })
// after
Ok(SchemaObject {
subschemas: Some(Box::new(SubschemaValidation {
all_of: Some(vec![schema]),
..Default::default()
})),
..Default::default()
}) Defensive patterns
Strategy: validation
Validate before calling
fn validate_subschemas(s: &SchemaObject) -> Result<(), String> {
if let Some(sub) = &s.subschemas {
if sub.all_of.is_none() && sub.any_of.is_none() && sub.one_of.is_none() {
return Err("subschema object present but has no all_of/any_of/one_of".into());
}
}
Ok(())
} Type guard
fn has_all_of(sub: &SubschemaValidation) -> bool { sub.all_of.is_some() } Try / catch
let all_of = match subschemas.all_of.take() {
Some(v) => v,
None => return Err(GenerateError::InvalidOptionalSchema),
}; Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- can't run runner twice
- referenced schema must exist in definitions
- schema definition must exist
- schema definition must exist
- schema metadata must always be an object
AI-assisted analysis of vectordotdev/vector@bdb87aeaa4 (2026-09-16).
Data as JSON: /api/errors/a3f3c6b5beaecc1b.
Report an issue: GitHub.
Appendix: source
Thrown at lib/vector-config/src/schema/helpers.rs:388
};
schema = wrapped_schema;
}
Some(subschemas) => {
if let Some(any_of) = subschemas.any_of.as_mut() {
// A null schema is just another possible variant, so we add it directly.
any_of.push(Schema::Object(generate_null_schema()));
} else if let Some(one_of) = subschemas.one_of.as_mut() {
// A null schema is just another possible variant, so we add it directly.
one_of.push(Schema::Object(generate_null_schema()));
} else if subschemas.all_of.is_some() {
// If we're dealing with an all-of schema, we have to build a new one-of schema
// where the two choices are either the `null` schema, or a subschema comprised of
// the all-of subschemas.
let all_of = subschemas
.all_of
.take()
.expect("all-of subschemas must be present here");
let new_all_of_schema = SchemaObject {
subschemas: Some(Box::new(SubschemaValidation {
all_of: Some(all_of),
..Default::default()
})),
..Default::default()
};
subschemas.one_of = Some(vec![
Schema::Object(generate_null_schema()),
Schema::Object(new_all_of_schema),
]);
} else {
return Err(GenerateError::InvalidOptionalSchema);
}
}
},
Some(sov) => match sov {View on GitHub (pinned to bdb87aeaa4)