{"record":{"id":"80dfe6e03f7aa714","repo":"cayleygraph/cayley","slug":"unsupported-value-v","errorCode":null,"errorMessage":"unsupported value: %#v","messagePattern":"unsupported value: %#v","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"graph/nosql/quadstore.go","lineNumber":612,"sourceCode":"\t\treturn vt, nil\n\t}\n\tvs, ok := d[fldValData].(nosql.String)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"unknown value format: %T\", d[fldValData])\n\t}\n\tif len(d) == 1 {\n\t\treturn quad.String(vs), nil\n\t}\n\tif ok, _ := d[fldIRI].(nosql.Bool); ok {\n\t\treturn quad.IRI(vs), nil\n\t} else if ok, _ := d[fldBNode].(nosql.Bool); ok {\n\t\treturn quad.BNode(vs), nil\n\t} else if typ, ok := d[fldType].(nosql.String); ok {\n\t\treturn quad.TypedString{Value: quad.String(vs), Type: quad.IRI(typ)}, nil\n\t} else if typ, ok := d[fldLang].(nosql.String); ok {\n\t\treturn quad.LangString{Value: quad.String(vs), Lang: string(typ)}, nil\n\t}\n\treturn nil, fmt.Errorf(\"unsupported value: %#v\", d)\n}\n\nfunc (qs *QuadStore) Quad(val graph.Ref) (quad.Quad, error) {\n\th := val.(QuadHash)\n\tvar q quad.Quad\n\tvar err error\n\tq.Subject, err = qs.NameOf(NodeHash(h.Get(quad.Subject)))\n\tif err != nil {\n\t\treturn q, err\n\t}\n\tq.Predicate, err = qs.NameOf(NodeHash(h.Get(quad.Predicate)))\n\tif err != nil {\n\t\treturn q, err\n\t}\n\tq.Object, err = qs.NameOf(NodeHash(h.Get(quad.Object)))\n\tif err != nil {\n\t\treturn q, err\n\t}","sourceCodeStart":594,"sourceCodeEnd":630,"githubUrl":"https://github.com/cayleygraph/cayley/blob/81dcd7d73e45136bc0d01802a8ba4685d8a533eb/graph/nosql/quadstore.go#L594-L630","documentation":"After extracting the string value, toQuadValue decides the value kind via the \"iri\", \"bnode\", \"type\" and \"lang\" document fields. If none match, the document represents no known quad.Value variant, so it is rejected with the full document dumped for debugging.","triggerScenarios":"Reading a document whose discriminator fields are absent or corrupted — e.g. missing both \"iri\" and \"bnode\" flags and no \"type\"/\"lang\" — while converting a stored ref back to a quad.Quad via Quad/NameOf.","commonSituations":"Store corruption, partial writes interrupted mid-commit, or documents produced by an incompatible writer version.","solutions":["Dump the document (%#v in the message) and check which discriminator keys are missing","Re-import the original dataset into a fresh store","Upgrade/downgrade Cayley so reader and writer versions match","Report/patch if a new quad.Value kind was serialized but the reader predates it"],"exampleFix":"// before\nq, err := qs.Quad(h)\n// after: check document discriminators before conversion\nif doc[fldIRI].(nosql.Bool) || doc[fldBNode].(nosql.Bool) {\n    q, err = qs.Quad(h)\n} else {\n    return fmt.Errorf(\"unusable document %v\", doc)\n}","handlingStrategy":"type-guard","validationCode":"_, hasIRI := doc[\"iri\"].(nosql.Bool); _, hasBNode := doc[\"bnode\"].(nosql.Bool); _, hasType := doc[\"type\"].(nosql.String); _, hasLang := doc[\"lang\"].(nosql.String)\nif !hasIRI && !hasBNode && !hasType && !hasLang { return fmt.Errorf(\"unusable document %v\", doc) }","typeGuard":"func knownValueKind(d map[string]interface{}) bool {\n    if b, ok := d[fldIRI].(nosql.Bool); ok && bool(b) { return true }\n    if b, ok := d[fldBNode].(nosql.Bool); ok && bool(b) { return true }\n    _, ok := d[fldType].(nosql.String); if ok { return true }\n    _, ok = d[fldLang].(nosql.String); return ok\n}","tryCatchPattern":"q, err := qs.Quad(h)\nif err != nil {\n    log.Warnf(\"cannot decode quad %v: %v\", h, err)\n    continue\n}","preventionTips":["Avoid manual edits to the KV store","Rebuild stores after unclean shutdowns if errors appear","Keep reader/writer versions in sync","Log and quarantine undecodable documents instead of aborting whole queries"],"tags":["nosql","type-mismatch","corrupt-data"],"backgroundTag":"type-mismatch","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"}