{"record":{"id":"94f0b962822e912e","repo":"ory/kratos","slug":"could-not-add-swagger-schema-to-the-schema-compile","errorCode":null,"errorMessage":"Could not add swagger schema to the schema compiler. This is an error with the binary you use and should be reported. Thanks ;)","messagePattern":"Could not add swagger schema to the schema compiler\\. This is an error with the binary you use and should be reported\\. Thanks ;\\)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/identities/validate.go","lineNumber":90,"sourceCode":"}\n\nvar schemas = make(map[string]*jsonschema.Schema)\n\nconst createIdentityPath = \"api.json#/components/schemas/createIdentityBody\"\n\ntype SchemaGetter = func(ctx context.Context, id string) (map[string]interface{}, *http.Response, error)\n\n// ValidateIdentity validates the json payload fc against\n// 1. the swagger payload definition and\n// 2. the remote custom identity schema.\nfunc ValidateIdentity(cmd *cobra.Command, src, i string, getRemoteSchema SchemaGetter) error {\n\tswaggerSchema, ok := schemas[createIdentityPath]\n\tif !ok {\n\t\t// add swagger schema\n\t\tschemaCompiler := jsonschema.NewCompiler()\n\t\terr := schemaCompiler.AddResource(\"api.json\", bytes.NewReader(spec.API))\n\t\tif err != nil {\n\t\t\treturn 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 ;)\")\n\t\t}\n\n\t\t// compile swagger payload definition\n\t\tswaggerSchema, err = schemaCompiler.Compile(cmd.Context(), createIdentityPath)\n\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, \"Could not compile the identity schema. This is an error with the binary you use and should be reported. Thanks ;)\")\n\t\t}\n\t\t// force additional properties to false because swagger does not render this\n\t\tswaggerSchema.AdditionalProperties = false\n\t\tschemas[createIdentityPath] = swaggerSchema\n\t}\n\n\t// validate against swagger definition\n\tvar foundValidationErrors bool\n\terr := swaggerSchema.Validate(bytes.NewBufferString(i))\n\tif err != nil {\n\t\t_, _ = fmt.Fprintf(cmd.ErrOrStderr(), \"%s: not valid\\n\", src)\n\t\tjsonschemax.FormatValidationErrorForCLI(cmd.ErrOrStderr(), []byte(i), err)","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/ory/kratos/blob/b86338da04a040247a07f46100a86dcfb3875909/cmd/identities/validate.go#L72-L108","documentation":"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.","triggerScenarios":"Thrown at cmd/identities/validate.go:90 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b86338da04a040247a07f46100a86dcfb3875909","analyzedAt":"2026-09-07T15:58:15.934Z","contentChangedAt":"2026-09-07T15:58:15.934Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}