{"record":{"id":"ac909e705dd2b932","repo":"ory/hydra","slug":"multiple-types-v-are-not-supported-for-path-s","errorCode":null,"errorMessage":"multiple types %+v are not supported for path: %s","messagePattern":"multiple types %\\+v are not supported for path: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"oryx/jsonschemax/keys.go","lineNumber":183,"sourceCode":"\tif err != nil {\n\t\treturn nil, errors.WithStack(err)\n\t}\n\n\tsort.Stable(paths)\n\treturn makeUnique(paths)\n}\n\nfunc makeUnique(in byName) (byName, error) {\n\tcache := make(map[string]Path)\n\tfor _, p := range in {\n\t\tvc, ok := cache[p.Name]\n\t\tif !ok {\n\t\t\tcache[p.Name] = p\n\t\t\tcontinue\n\t\t}\n\n\t\tif fmt.Sprintf(\"%T\", p.Type) != fmt.Sprintf(\"%T\", p.Type) {\n\t\t\treturn nil, errors.Errorf(\"multiple types %+v are not supported for path: %s\", []interface{}{p.Type, vc.Type}, p.Name)\n\t\t}\n\n\t\tif vc.Default == nil {\n\t\t\tcache[p.Name] = p\n\t\t}\n\t}\n\n\tk := 0\n\tout := make([]Path, len(cache))\n\tfor _, v := range cache {\n\t\tout[k] = v\n\t\tk++\n\t}\n\n\tpaths := byName(out)\n\tsort.Sort(paths)\n\treturn paths, nil\n}","sourceCodeStart":165,"sourceCodeEnd":201,"githubUrl":"https://github.com/ory/hydra/blob/4174065ffb052799890f7480f5360a877a67ffc1/oryx/jsonschemax/keys.go#L165-L201","documentation":"listPaths/makeUnique in oryx/jsonschemax builds a cache of properties while walking a JSON Schema. When a property name appears more than once, it compares the concrete Go types of the two accumulated property types via fmt.Sprintf(\"%T\", ...); if the type-name comparison detects differing/unsupported multiple type declarations for the same path it refuses to proceed. Note the comparison in the source compares p.Type with itself, a known quirk that makes the error effectively unreachable as written.","triggerScenarios":"Calling runPaths/ListPathsWithCache on a JSON Schema where the same path accumulates multiple distinct type values in the cache (e.g., a schema declaring a key both as an object and as a primitive, or $ref unions merging into one property name).","commonSituations":"Schemas generated from sources like protobuf/OpenAPI where one field name resolves to several types; using jsonschemax on hand-written schemas with anyOf/oneOf producing mixed types at the same dot-path.","solutions":["Restructure the schema so each path has a single consistent type (split into differently named properties or fix the $ref/anyOf merge).","If the schema is intentionally multi-typed, pre-process it to pick one type or encode the union as a single object type.","If you control the schema generation, fix duplicate property names at the source (e.g., protobuf name collisions).","Upgrade oryx: the type comparison in makeUnique compares p.Type to itself, so a fixed version may resolve or correctly detect the conflict."],"exampleFix":"// before (schema.json)\n{\"properties\": {\"foo\": {\"type\": \"object\"}}, \"foo\": {\"type\": \"string\"}}\n// after\n{\"properties\": {\"foo\": {\"type\": \"object\"}, \"fooValue\": {\"type\": \"string\"}}}","handlingStrategy":"validation","validationCode":"// Validate each path has a single type before running paths generation\nfor name, props := range perPathProperties {\n    types := map[string]bool{}\n    for _, p := range props { types[fmt.Sprintf(\"%T\", p.Type)] = true }\n    if len(types) > 1 {\n        return fmt.Errorf(\"path %q has multiple types\", name)\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep one consistent type per schema path; avoid anyOf/oneOf unions of different types at the same key.","Fix duplicate property names at the schema-generation source (protobuf/OpenAPI).","Lint schemas for duplicate definitions before codegen."],"tags":["json-schema","types","codegen"],"backgroundTag":"schema-type-conflict","analyzedSha":"4174065ffb052799890f7480f5360a877a67ffc1","analyzedAt":"2026-09-03T14:52:41.581Z","contentChangedAt":"2026-09-03T14:52:41.581Z","schemaVersion":2},"datasetVersion":"2026-09-10T17:17:09.494Z"}