bevyengine/bevy · error
Missing `relationship_target = X` attribute
Error message
Missing `relationship_target = X` attribute
What it means
Compile error from parsing #[relationship_target] attribute options in the Relationship derive macro: the parser saw the `relationship_target` keyword but failed to consume the required `= X` (target relationship type) part, or an unrecognized token followed it. The lookahead1 error is a generic sentinel for a malformed attribute token stream at that position.
Source
Thrown at crates/bevy_ecs/macro_logic/src/component.rs:755
while !input.is_empty() {
let lookahead = input.lookahead1();
if lookahead.peek(kw::allow_self_referential) {
input.parse::<kw::allow_self_referential>()?;
allow_self_referential = true;
} else if lookahead.peek(kw::relationship_target) {
input.parse::<kw::relationship_target>()?;
input.parse::<Token![=]>()?;
relationship_target = Some(input.parse()?);
} else {
return Err(lookahead.error());
}
if !input.is_empty() {
input.parse::<Token![,]>()?;
}
}
Ok(Relationship {
relationship_target: relationship_target.ok_or_else(|| {
syn::Error::new(input.span(), "Missing `relationship_target = X` attribute")
})?,
allow_self_referential,
})
}
}
impl Parse for RelationshipTarget {
fn parse(input: syn::parse::ParseStream) -> Result<Self> {
let mut relationship: Option<Type> = None;
let mut linked_spawn: bool = false;
while !input.is_empty() {
let lookahead = input.lookahead1();
if lookahead.peek(kw::linked_spawn) {
input.parse::<kw::linked_spawn>()?;
linked_spawn = true;
} else if lookahead.peek(kw::relationship) {
input.parse::<kw::relationship>()?;View on GitHub (pinned to 396ca72708)
Solutions
- Write the attribute as #[relationship_target = RelationshipType] with a literal `=` and a valid type path
- Ensure no stray tokens or typos (e.g. missing comma between attribute options like relationship_target = X, relationship_verified) follow the value
- Separate multiple options with commas: #[relationship_target = Child, relationship_verified)]
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/bevy_ecs/macro_logic/src/component.rs:755 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of bevyengine/bevy@396ca72708 (2026-08-20).
Data as JSON: /api/errors/d4a847285acd65c6.
Report an issue: GitHub.