{"record":{"id":"239b42284c518b75","repo":"facebook/relay","slug":"metadata-directive-should-have-only-one-argumen","errorCode":null,"errorMessage":"@__metadata directive should have only one argument!","messagePattern":"@__metadata directive should have only one argument!","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"compiler/crates/relay-codegen/src/build_ast.rs","lineNumber":388,"sourceCode":"            definition_source_location,\n        }\n    }\n\n    fn object(&mut self, object: Vec<ObjectEntry>) -> AstKey {\n        self.ast_builder.intern(Ast::Object(object))\n    }\n\n    fn array(&mut self, array: Vec<Primitive>) -> AstKey {\n        self.ast_builder.intern(Ast::Array(array))\n    }\n\n    fn build_internal_metadata_directives(&mut self, directives: &[Directive]) -> Vec<ObjectEntry> {\n        directives\n            .iter()\n            .filter_map(|directive| {\n                if directive.name.item == *INTERNAL_METADATA_DIRECTIVE {\n                    if directive.arguments.len() != 1 {\n                        panic!(\"@__metadata directive should have only one argument!\");\n                    }\n\n                    let arg = &directive.arguments[0];\n                    let key = arg.name.item;\n                    let value = match &arg.value.item {\n                        Value::Constant(value) => self.build_constant_value(value),\n                        _ => {\n                            panic!(\"@__metadata directive expect only constant argument values.\");\n                        }\n                    };\n\n                    Some(ObjectEntry { key: key.0, value })\n                } else {\n                    None\n                }\n            })\n            .collect()\n    }","sourceCodeStart":370,"sourceCodeEnd":406,"githubUrl":"https://github.com/facebook/relay/blob/668b1b85e06261aa3b58dabfc51f8b5524a70955/compiler/crates/relay-codegen/src/build_ast.rs#L370-L406","documentation":"When building codegen AST metadata, the @__metadata directive must carry exactly one argument. build_internal_metadata_directives panics if directive.arguments.len() != 1, since internal metadata is encoded as a single key/value entry.","triggerScenarios":"A GraphQL document contains `@__metadata` with zero or multiple arguments, encountered while building fragment metadata (build_fragment_metadata) or request parameters (build_request_parameters).","commonSituations":"Hand-editing a fragment with @__metadata and dropping or adding arguments; an older/newer compiler version emitting a different @__metadata shape than the consumer expects; a code generator writing malformed metadata directives.","solutions":["Edit the document so @__metadata has exactly one argument, e.g. @__metadata(parentType: \"Query\").","Regenerate the file with the same relay compiler version that consumes it instead of hand-editing generated code.","If you manage multiple compiler versions, align the version producing @__metadata with the version parsing it.","Remove stray @__metadata directives that were accidentally left in hand-written fragments."],"exampleFix":"// before\nfragment FooResolver on Query @__metadata(a: \"x\", b: \"y\") { ... }\n// after\nfragment FooResolver on Query @__metadata(parentType: \"Query\") { ... }\n","handlingStrategy":"validation","validationCode":"fn validate_metadata_directive(d: &Directive) -> Result<(), String> {\n    if d.name.item.0 == \"__metadata\" && d.arguments.len() != 1 {\n        return Err(\"@__metadata must have exactly one argument\".into());\n    }\n    Ok(())\n}\n","typeGuard":null,"tryCatchPattern":"let result = std::panic::catch_unwind(|| build_fragment_metadata(...));\nif result.is_err() { report(\"invalid @__metadata directive shape\"); }\n","preventionTips":["Never hand-edit @__metadata directives; regenerate them with the compiler.","Validate all @__metadata directives have exactly one argument in a lint pass.","Pin one relay compiler version for both emitting and consuming metadata."],"tags":["graphql","directive","metadata","panic"],"backgroundTag":"invalid-directive-argument","analyzedSha":"668b1b85e06261aa3b58dabfc51f8b5524a70955","analyzedAt":"2026-09-02T19:57:20.783Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}