{"record":{"id":"f65d1d5cef451c13","repo":"ory/kratos","slug":"unexpected-node-type-s","errorCode":null,"errorMessage":"unexpected node type: %s","messagePattern":"unexpected node type: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"ui/node/node.go","lineNumber":521,"sourceCode":"\t\t}\n\tcase Anchor:\n\t\tattr = &AnchorAttributes{\n\t\t\tNodeType: Anchor,\n\t\t}\n\tcase Image:\n\t\tattr = &ImageAttributes{\n\t\t\tNodeType: Image,\n\t\t}\n\tcase Script:\n\t\tattr = &ScriptAttributes{\n\t\t\tNodeType: Script,\n\t\t}\n\tcase Division:\n\t\tattr = &DivisionAttributes{\n\t\t\tNodeType: Division,\n\t\t}\n\tdefault:\n\t\treturn fmt.Errorf(\"unexpected node type: %s\", t)\n\t}\n\n\tvar d jsonRawNode\n\td.Attributes = attr\n\tif err := json.NewDecoder(bytes.NewReader(data)).Decode(&d); err != nil {\n\t\treturn err\n\t}\n\n\t*n = Node(d)\n\n\tif n.Meta == nil {\n\t\tn.Meta = new(Meta)\n\t}\n\n\treturn nil\n}\n\nfunc (n *Node) MarshalJSON() ([]byte, error) {","sourceCodeStart":503,"sourceCodeEnd":539,"githubUrl":"https://github.com/ory/kratos/blob/b86338da04a040247a07f46100a86dcfb3875909/ui/node/node.go#L503-L539","documentation":"During node JSON deserialization (UnmarshalJSON in ui/node/node.go), the \"type\" discriminator is matched against known node types (e.g. Division, Script) to select the right Attributes struct. An unknown type string means the JSON carries a node type this version of the library does not implement, so it cannot build the corresponding attributes struct.","triggerScenarios":"Unmarshaling a message/flow payload whose nodes contain a \"type\" value that this library version does not recognize — typically produced by a newer Ory server (new UI node types like text, image, input variants) while the client SDK is older.","commonSituations":"SDK version lagging behind the Kratos server version after an upgrade; hand-edited or fixture JSON with a typo in the node type; custom node types injected by an Ory Network update.","solutions":["Upgrade the Ory client/SDK to a version matching (or newer than) the server that produced the payload.","Log the reported node type and check the library's NodeType enum for the closest supported value.","Fix typos in hand-written JSON fixtures so the type matches the enum exactly.","As a stopgap, strip unknown nodes from the raw JSON before unmarshaling."],"exampleFix":"// before (older SDK)\nresp, _, _ := api.FrontendApi.GetRegistrationFlow(ctx, id) // node type \"captcha\" unknown\n// after\n// go get github.com/ory/kratos-client-go@latest  (supports the new node type)","handlingStrategy":"try-catch","validationCode":"// Check the payload's node types against the SDK enum before unmarshaling:\nvar probe struct{ Nodes []struct{ Type string `json:\"type\"` } `json:\"nodes\"` }\n_ = json.Unmarshal(raw, &probe)\nfor _, n := range probe.Nodes {\n    if !isKnownNodeType(n.Type) { /* skip or upgrade SDK */ }\n}","typeGuard":"func isKnownNodeType(t string) bool {\n    switch ui.NodeType(t) {\n    case ui.Text, ui.Image, ui.Input, ui.Anchor, ui.Script, ui.Division:\n        return true\n    }\n    return false\n}","tryCatchPattern":"if err := json.Unmarshal(data, &flow); err != nil {\n    if strings.Contains(err.Error(), \"unexpected node type\") {\n        log.Warn(\"server sent unknown UI node type; upgrade SDK\", \"err\", err)\n        // fall back to raw JSON handling or skip nodes\n    }\n}","preventionTips":["Keep the Kratos client SDK version aligned with your server version.","Pin and update SDK dependencies as part of server upgrades.","Validate flow JSON fixtures against the SDK's NodeType enum."],"tags":["json","unmarshal","ui-nodes","version-mismatch"],"backgroundTag":"unsupported-enum-value","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"}