{"record":{"id":"18a89d3d43aaa1dc","repo":"facebook/relay","slug":"expected-docblocks-to-only-expose-object-and-scala","errorCode":null,"errorMessage":"Expected docblocks to only expose object and scalar definitions, and object and interface extensions.","messagePattern":"Expected docblocks to only expose object and scalar definitions, and object and interface extensions\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"compiler/crates/relay-compiler/src/build_project/build_resolvers_schema/mark_document_as_base.rs","lineNumber":69,"sourceCode":"                    &def.directives,\n                    &[belongs_to_base_schema_directive()],\n                ),\n                ..def\n            })\n        }\n        TypeSystemDefinition::ObjectTypeExtension(def) => {\n            TypeSystemDefinition::ObjectTypeExtension(ObjectTypeExtension {\n                fields: mark_fields_as_base(def.fields),\n                ..def\n            })\n        }\n        TypeSystemDefinition::InterfaceTypeExtension(def) => {\n            TypeSystemDefinition::InterfaceTypeExtension(InterfaceTypeExtension {\n                fields: mark_fields_as_base(def.fields),\n                ..def\n            })\n        }\n        _ => panic!(\n            \"Expected docblocks to only expose object and scalar definitions, and object and interface extensions.\"\n        ),\n    }\n}\n\n/// Mark fields as base schema extension fields\nfn mark_fields_as_base(fields: Option<List<FieldDefinition>>) -> Option<List<FieldDefinition>> {\n    fields.map(|list| List {\n        items: list\n            .items\n            .iter()\n            .map(|item| FieldDefinition {\n                directives: merge_directives(\n                    &item.directives,\n                    &[belongs_to_base_schema_directive()],\n                ),\n                ..item.clone()\n            })","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/facebook/relay/blob/668b1b85e06261aa3b58dabfc51f8b5524a70955/compiler/crates/relay-compiler/src/build_project/build_resolvers_schema/mark_document_as_base.rs#L51-L87","documentation":"mark_extension_as_base panics on any TypeSystemDefinition other than object/scalar definitions or object/interface extensions. Docblock-driven schema extensions are limited to that set; anything else (e.g. union/enum extensions) should have been filtered earlier.","triggerScenarios":"A docblock produces a schema definition/extension of an unsupported kind (e.g. a union or enum extension) that reaches mark_extension_as_base during mark_document_as_base.","commonSituations":"A resolver docblock tries to extend a union or enum, or the docblock parser emits extension kinds the base-marking step doesn't support.","solutions":["Restrict docblock extensions to objects/scalars (definitions) and object/interface extensions","Convert the union/enum extension into a full definition or a supported extension form","Report upstream if a supported construct reaches this panic (parser/mark step contract violation)"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Filter unsupported definitions before calling mark_extension_as_base\nlet supported = matches!(def,\n    TypeSystemDefinition::ObjectType(_) | TypeSystemDefinition::ScalarType(_)\n      | TypeSystemDefinition::ObjectTypeExtension(_)\n      | TypeSystemDefinition::InterfaceTypeExtension(_));\nif !supported { return Err(\"unsupported docblock schema definition\"); }","typeGuard":"fn is_markable(d: &TypeSystemDefinition) -> bool {\n    matches!(d,\n        TypeSystemDefinition::ObjectType(_)\n        | TypeSystemDefinition::ScalarType(_)\n        | TypeSystemDefinition::ObjectTypeExtension(_)\n        | TypeSystemDefinition::InterfaceTypeExtension(_))\n}","tryCatchPattern":"// not catchable; guard with is_markable and surface an unsupported-extension diagnostic","preventionTips":["Only define/extend objects, scalars, and object/interface extensions from docblocks","Never emit union/enum extensions from docblock tooling","Cover mark_document_as_base with tests over all TypeSystemDefinition variants"],"tags":["compiler","rust","panic","graphql-schema","docblock"],"backgroundTag":"unsupported-schema-extension","analyzedSha":"668b1b85e06261aa3b58dabfc51f8b5524a70955","analyzedAt":"2026-09-02T19:57:20.783Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}