gitbutlerapp/gitbutler · error
Error when registering schema
Error message
Error when registering schema {} for type {} registered at {}
Missing dependent type {}. Consider deriving `JsonSchema` on the type and registering it with `register_sdk_type!()`.
What it means
When registering a schema, but-ts walks the generated `$defs`/`definitions` of a type's schema and requires every dependent type to already be registered. A `$ref` to a name that is not in `existing_names` means a referenced `JsonSchema` type was never registered, so the generated binding would contain a dangling reference; the tool aborts.
Solutions
- Derive `JsonSchema` on the missing dependent type and add a `register_sdk_type!()` call for it in the same source crate.
- If the dependency should be inlined, annotate the field with `#[schemars(inline)]` instead of relying on a `$ref`.
- Check the `def_name` in the error against the registration list in crates/but-ts to confirm which type is missing.
Example fix
// before
// (no registration for Author)
pub struct Commit { pub author: Author }
// after
register_sdk_type!(crate::author::Author);
pub struct Commit { pub author: Author } Defensive patterns
Strategy: validation
Validate before calling
for dep in &schema["$defs"] {
assert!(registered.contains_key(dep.key()), "unregistered dependency: {}", dep.key());
} Prevention
- Every type reachable from a registered type must derive JsonSchema and be registered with register_sdk_type!().
- When adding a field of a new type, immediately add its registration.
- Run but-ts as part of CI to catch missing registrations before release.
When it happens
Trigger: Registering a type via `register_sdk_type!()` whose schema references a nested type that does not derive `JsonSchema` registration — i.e. the dependency was never passed to `register_sdk_type!()` itself.
Common situations: Adding a field of a new nested type to a registered struct and forgetting to register the nested type; conditional compilation (`#[cfg]`) hiding the dependency registration on some platforms; a dependency removed from the registration list during refactoring.
Understand the failure class
Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.
Related errors
- Error when registering schema
- Error when registering schema
- existing GitMeta key
- existing GitMeta key
- existing GitMeta key
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/fd5b2c446d9cea3b.
Report an issue: GitHub.
Appendix: source
Thrown at crates/but-ts/src/main.rs:446
for t in &types {
if let Some(obj) = t.schema.as_object()
&& let Some(serde_json::Value::Object(defs)) =
obj.get("$defs").or_else(|| obj.get("definitions"))
{
for (def_name, def_schema) in defs {
if let Some(entry) = existing_names.get(&def_name.as_ref()) {
let entry_schema = entry.schema.clone().to_value();
if !root_equals_def(&entry_schema, def_schema, def_name) {
bail!(
"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",
t.name,
t.type_name,
t.registration_location,
def_name
)
}
} else {
bail!(
"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",
t.name,
t.type_name,
t.registration_location,
def_name
)
}
}
}
}
// Order output types by name
types.sort_by(|a, b| a.name.cmp(&b.name));
Ok(types
.into_iter()
.map(|s| (s.name.to_string(), s.schema))
.collect())View on GitHub (pinned to 58e5313667)