{"record":{"id":"fd4ddac7a933a365","repo":"gitbutlerapp/gitbutler","slug":"error-when-registering-schema-for-type-regis","errorCode":null,"errorMessage":"Error when registering schema {} for type {} registered at {}\n\nThe registered dependent type {} has a different signature than what is expected. This indicates a potential name collision. Consider renaming one of the types with either `#[serde(rename = ...)]` or `#[schemars(rename = ...)]`.\n","messagePattern":"Error when registering schema (.+?) for type (.+?) registered at (.+?)\n\nThe registered dependent type (.+?) has a different signature than what is expected\\. This indicates a potential name collision\\. Consider renaming one of the types with either `#\\[serde\\(rename = \\.\\.\\.\\)\\]` or `#\\[schemars\\(rename = \\.\\.\\.\\)\\]`\\.\n","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-ts/src/main.rs","lineNumber":437,"sourceCode":"                t.registration_location,\n                duplicate.type_name,\n                duplicate.registration_location\n            );\n        } else {\n            existing_names.insert(t.name.as_ref(), t);\n        }\n    }\n\n    for t in &types {\n        if let Some(obj) = t.schema.as_object()\n            && let Some(serde_json::Value::Object(defs)) =\n                obj.get(\"$defs\").or_else(|| obj.get(\"definitions\"))\n        {\n            for (def_name, def_schema) in defs {\n                if let Some(entry) = existing_names.get(&def_name.as_ref()) {\n                    let entry_schema = entry.schema.clone().to_value();\n                    if !root_equals_def(&entry_schema, def_schema, def_name) {\n                        bail!(\n                            \"Error when registering schema {} for type {} registered at {}\\n\\nThe registered dependent type {} has a different signature than what is expected. This indicates a potential name collision. Consider renaming one of the types with either `#[serde(rename = ...)]` or `#[schemars(rename = ...)]`.\\n\",\n                            t.name,\n                            t.type_name,\n                            t.registration_location,\n                            def_name\n                        )\n                    }\n                } else {\n                    bail!(\n                        \"Error when registering schema {} for type {} registered at {}\\n\\nMissing dependent type {}. Consider deriving `JsonSchema` on the type and registering it with `register_sdk_type!()`.\\n\",\n                        t.name,\n                        t.type_name,\n                        t.registration_location,\n                        def_name\n                    )\n                }\n            }\n        }","sourceCodeStart":419,"sourceCodeEnd":455,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-ts/src/main.rs#L419-L455","documentation":"While registering a schema, but-ts found an already-registered dependent type (a `$defs`/`definitions` entry) whose schema body differs from the schema previously registered under the same name. Since `$ref` resolution requires identical bodies, this signals a name collision between two different types, and generation aborts.","triggerScenarios":"Registering a type whose schema inlines a `$defs` entry with a name that was already registered by another type, but with a different shape, so `root_equals_def` comparison fails in `collect_all_schemas`.","commonSituations":"Two crates each define a helper type with the same name (e.g. `CommitId`) used as a dependency of registered SDK types; a type was renamed only at the top level, leaving dependent definitions colliding.","solutions":["Rename one of the colliding dependent types with `#[serde(rename = ...)]` / `#[schemars(rename = ...)]` so the `$defs` names are unique.","Register the dependent type explicitly with `register_sdk_type!()` so the definitions reconcile to a single shared schema.","Compare the two schemas referenced by the error to confirm whether the shape difference is intended or a stale duplicate."],"exampleFix":"// before (crate B)\n#[derive(JsonSchema)]\npub struct CommitId(pub String);\n// after\n#[derive(JsonSchema)]\n#[schemars(rename = \"CommitIdV2\")]\npub struct CommitId(pub String);","handlingStrategy":"validation","validationCode":"let def_names: HashSet<_> = schema[\"$defs\"].as_object().unwrap().keys().collect();\nlet already: HashSet<_> = existing.keys().collect();\nlet overlaps: Vec<_> = def_names.intersection(&already).collect();\nif !overlaps.is_empty() { /* verify shapes match or rename */ }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Register shared dependent types once, centrally, instead of letting each schema inline its own copy.","Avoid same-named helper types across crates used by the SDK.","Regenerate TS bindings locally after adding nested types."],"tags":["code-generation","schema","naming-collision","json-schema"],"backgroundTag":"schema-validation-failed","analyzedSha":"58e5313667b857ef39a730e380af31816a7b1768","analyzedAt":"2026-09-18T06:50:32.052Z","contentChangedAt":"2026-09-18T06:50:32.052Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}