{"record":{"id":"dc5be1e95645ba79","repo":"facebook/relay","slug":"can-only-insert-once-had-and-trying-to","errorCode":null,"errorMessage":"Can only insert '{}' once. Had {:?} and trying to insert {:?}.","messagePattern":"Can only insert '(.+?)' once\\. Had (.+?) and trying to insert (.+?)\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"compiler/crates/graphql-ir/src/program.rs","lineNumber":80,"sourceCode":"                        panic!(\n                            \"\\nDuplicate fragment definitions named {}: \\nfirst one: {:?}\\nsecond one: {:?}\\n\",\n                            name, loc, &another.name.location\n                        );\n                    }\n                }\n            }\n        }\n        Self {\n            schema,\n            fragments,\n            operations,\n        }\n    }\n\n    pub fn insert_fragment(&mut self, fragment: Arc<FragmentDefinition>) {\n        let name = fragment.name.item;\n        if let Some(previous) = self.fragments.insert(name, fragment) {\n            panic!(\n                \"Can only insert '{}' once. Had {:?} and trying to insert {:?}.\",\n                name, previous, self.fragments[&name]\n            );\n        };\n    }\n\n    pub fn fragment(&self, name: FragmentDefinitionName) -> Option<&Arc<FragmentDefinition>> {\n        self.fragments.get(&name)\n    }\n\n    pub fn fragment_mut(\n        &mut self,\n        name: FragmentDefinitionName,\n    ) -> Option<&mut Arc<FragmentDefinition>> {\n        self.fragments.get_mut(&name)\n    }\n\n    /// Searches for an operation by name.","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/facebook/relay/blob/668b1b85e06261aa3b58dabfc51f8b5524a70955/compiler/crates/graphql-ir/src/program.rs#L62-L98","documentation":"Panic in Program::insert_fragment: a fragment was inserted under a name that already exists in the program's fragment map. The previous and new fragment locations are printed. This invariant check fires during compiler transforms that add fragments (e.g. refetchable/connection transforms) when they generate or copy a fragment whose name collides with an existing one.","triggerScenarios":"Thrown at compiler/crates/graphql-ir/src/program.rs:80 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check custom transforms that call insert_fragment for name collisions with existing fragments","Avoid defining a fragment whose name matches a compiler-generated one (e.g. from @refetchable or @connection)","If it reproduces with plain Relay code, report a compiler issue with the fragment definitions involved"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"668b1b85e06261aa3b58dabfc51f8b5524a70955","analyzedAt":"2026-09-02T19:57:20.783Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}