ory/kratos · error
Could not add swagger schema to the schema compiler. This…
Error message
Could not add swagger schema to the schema compiler. This is an error with the binary you use and should be reported. Thanks ;)
What it means
ValidateIdentity lazily compiles the embedded swagger schema (api.json createIdentityBody) into the JSON Schema compiler on first use, and that compilation step failed. Since the schema is embedded in the binary, this failure means the shipped binary itself is broken or its embedded asset is corrupted - it is not caused by user input.
Solutions
- Report the issue to the Ory maintainers with the binary version, as the message itself requests
- Re-download or rebuild the kratos binary from a trusted source to rule out corruption
- Verify the binary version matches the API schema it ships with
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at cmd/identities/validate.go:90 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of ory/kratos@b86338da04 (2026-09-07).
Data as JSON: /api/errors/94f0b962822e912e.
Report an issue: GitHub.
Appendix: source
Thrown at cmd/identities/validate.go:90
}
var schemas = make(map[string]*jsonschema.Schema)
const createIdentityPath = "api.json#/components/schemas/createIdentityBody"
type SchemaGetter = func(ctx context.Context, id string) (map[string]interface{}, *http.Response, error)
// ValidateIdentity validates the json payload fc against
// 1. the swagger payload definition and
// 2. the remote custom identity schema.
func ValidateIdentity(cmd *cobra.Command, src, i string, getRemoteSchema SchemaGetter) error {
swaggerSchema, ok := schemas[createIdentityPath]
if !ok {
// add swagger schema
schemaCompiler := jsonschema.NewCompiler()
err := schemaCompiler.AddResource("api.json", bytes.NewReader(spec.API))
if err != nil {
return errors.Wrap(err, "Could not add swagger schema to the schema compiler. This is an error with the binary you use and should be reported. Thanks ;)")
}
// compile swagger payload definition
swaggerSchema, err = schemaCompiler.Compile(cmd.Context(), createIdentityPath)
if err != nil {
return errors.Wrap(err, "Could not compile the identity schema. This is an error with the binary you use and should be reported. Thanks ;)")
}
// force additional properties to false because swagger does not render this
swaggerSchema.AdditionalProperties = false
schemas[createIdentityPath] = swaggerSchema
}
// validate against swagger definition
var foundValidationErrors bool
err := swaggerSchema.Validate(bytes.NewBufferString(i))
if err != nil {
_, _ = fmt.Fprintf(cmd.ErrOrStderr(), "%s: not valid\n", src)
jsonschemax.FormatValidationErrorForCLI(cmd.ErrOrStderr(), []byte(i), err)View on GitHub (pinned to b86338da04)