{"record":{"id":"463f45324471eac1","repo":"cayleygraph/cayley","slug":"unsupported-type-v","errorCode":null,"errorMessage":"unsupported type: %v","messagePattern":"unsupported type: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"schema/writer.go","lineNumber":155,"sourceCode":"\t// check if it's a type that quads package supports\n\t// note, that it may be a struct such as time.Time\n\tif val, ok := quad.AsValue(rv.Interface()); ok {\n\t\treturn val, nil\n\t} else if kind == reflect.String {\n\t\treturn quad.String(rv.String()), nil\n\t} else if kind == reflect.Int || kind == reflect.Uint ||\n\t\tkind == reflect.Int32 || kind == reflect.Uint32 ||\n\t\tkind == reflect.Int16 || kind == reflect.Uint16 ||\n\t\tkind == reflect.Int8 || kind == reflect.Uint8 {\n\t\treturn quad.Int(rv.Int()), nil\n\t} else if kind == reflect.Float64 || kind == reflect.Float32 {\n\t\treturn quad.Float(rv.Float()), nil\n\t} else if kind == reflect.Bool {\n\t\treturn quad.Bool(rv.Bool()), nil\n\t}\n\t// TODO(dennwc): support maps\n\tif kind != reflect.Struct {\n\t\treturn nil, fmt.Errorf(\"unsupported type: %v\", rt)\n\t}\n\t// get conversion rules for this struct type\n\trules, err := w.c.rulesFor(rt)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"can't load rules: %v\", err)\n\t}\n\tif len(rules) == 0 {\n\t\treturn nil, fmt.Errorf(\"no rules for struct: %v\", rt)\n\t}\n\t// get an ID from the struct value\n\tid, err := w.c.idFor(rules, rt, rv, \"\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif id == nil {\n\t\tid = w.c.genID(prv.Interface())\n\t}\n\t// save a node ID to avoid loops","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/cayleygraph/cayley/blob/81dcd7d73e45136bc0d01802a8ba4685d8a533eb/schema/writer.go#L137-L173","documentation":"writeAsQuads converts Go values into quads and only handles strings, numerics, bools, and structs. If, after unwrapping, the reflect kind is not Struct (maps are also unsupported per the TODO), it cannot serialize the value and returns this error naming the type.","triggerScenarios":"Writing a value to the graph (via Writer/WriteAsQuads or schema write path) whose resolved kind is a map, channel, complex number, interface, or other non-struct non-scalar type.","commonSituations":"Attempting to store map[string]interface{} payloads; writing complex128 or chan fields; passing nil-interface values into the writer.","solutions":["Convert the value to a supported type (string, number, bool, or struct) before writing","Serialize maps to JSON strings before writing","Model nested data as structs with schema tags instead of maps"],"exampleFix":"// before\nw.WriteAsQuads(qs, val) // val is map[string]interface{}\n// after\nb, _ := json.Marshal(val)\nw.WriteAsQuads(qs, string(b))","handlingStrategy":"type-guard","validationCode":"func isWritable(v interface{}) bool {\n    rv := reflect.ValueOf(v)\n    for rv.Kind() == reflect.Ptr || rv.Kind() == reflect.Slice { rv = rv.Elem() }\n    switch rv.Kind() {\n    case reflect.String, reflect.Int, reflect.Float64, reflect.Bool, reflect.Struct:\n        return true\n    }\n    return false\n}","typeGuard":"func writableKind(v interface{}) (reflect.Kind, bool) {\n    rv := reflect.ValueOf(v)\n    for rv.Kind() == reflect.Ptr || rv.Kind() == reflect.Slice { rv = rv.Elem() }\n    switch rv.Kind() {\n    case reflect.String, reflect.Int, reflect.Float64, reflect.Bool, reflect.Struct:\n        return rv.Kind(), true\n    }\n    return rv.Kind(), false\n}","tryCatchPattern":"quads, err := w.WriteAsQuads(qs, val)\nif err != nil {\n    if strings.Contains(err.Error(), \"unsupported type:\") {\n        // convert maps/complex types to strings or structs first\n    }\n    return err\n}","preventionTips":["Avoid map fields in structs written to the graph - use JSON strings or nested structs","Pre-convert unsupported kinds before calling the writer","Cover write paths with tests for every mapped type"],"tags":["schema","serialization","unsupported-type"],"backgroundTag":"unsupported-operation","analyzedSha":"81dcd7d73e45136bc0d01802a8ba4685d8a533eb","analyzedAt":"2026-09-06T06:14:12.358Z","contentChangedAt":"2026-09-06T06:14:12.358Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}