{"record":{"id":"6891884fce98dec1","repo":"cayleygraph/cayley","slug":"unknown-value-format-t","errorCode":null,"errorMessage":"unknown value format: %T","messagePattern":"unknown value format: %T","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"graph/nosql/quadstore.go","lineNumber":598,"sourceCode":"\t} else if v, ok := d[fldValTime]; ok {\n\t\tvar vt quad.Time\n\t\tswitch v := v.(type) {\n\t\tcase nosql.Time:\n\t\t\tvt = quad.Time(v)\n\t\tcase nosql.String:\n\t\t\tvar t time.Time\n\t\t\tif err := t.UnmarshalJSON([]byte(`\"` + string(v) + `\"`)); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tvt = quad.Time(t)\n\t\tdefault:\n\t\t\treturn nil, fmt.Errorf(\"unexpected type for bool field: %T\", v)\n\t\t}\n\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)","sourceCodeStart":580,"sourceCodeEnd":616,"githubUrl":"https://github.com/cayleygraph/cayley/blob/81dcd7d73e45136bc0d01802a8ba4685d8a533eb/graph/nosql/quadstore.go#L580-L616","documentation":"toQuadValue converts a stored nosql document back into a quad.Value. The document's value field (\"str\") must hold a nosql.String; if it holds any other type (nil, nosql.Bool, a number, etc.) the document is corrupt or was written by an incompatible writer, so this error is thrown.","triggerScenarios":"Calling NameOf (or Quad) on a QuadHash whose underlying document lacks a nosql.String under the \"str\" key — typically a corrupted, hand-edited, or foreign document in the nosql backend.","commonSituations":"Data written by a different Cayley/nosql version, manual edits to a KV store (bolt/leveldb), or deserialization of a document that never went through toDocumentValue.","solutions":["Inspect the offending document and check which type the \"str\" field actually holds","Re-import the source data (nquads/JSONL) into a fresh store to rebuild the document","Verify the store was written and read with the same Cayley version","If handling externally-produced documents, validate document shape before calling toQuadValue"],"exampleFix":"// before: blindly converting a hash read from disk\nv, err := NameOf(h)\n// after: validate the document field first\nif _, ok := doc[fldValData].(nosql.String); !ok {\n    return fmt.Errorf(\"skipping malformed document %v\", doc)\n}\nv, err := NameOf(h)","handlingStrategy":"type-guard","validationCode":"if _, ok := doc[\"str\"].(nosql.String); !ok { return fmt.Errorf(\"document %v has no string value\", doc) }","typeGuard":"func isStringDoc(d map[string]interface{}) bool { _, ok := d[fldValData].(nosql.String); return ok }","tryCatchPattern":"v, err := toQuadValue(doc)\nif err != nil {\n    log.Warnf(\"skipping malformed document: %v\", err)\n    return nil // or fallback\n}","preventionTips":["Only feed documents produced by toDocumentValue into toQuadValue","Validate document shape when importing foreign data","Pin the same Cayley version for writer and reader","Checksum/verify store integrity after crashes"],"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-14T00:17:10.932Z"}