cayleygraph/cayley · error

unsupported value: %#v

Error message

unsupported value: %#v

What it means

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.

Source

Thrown at graph/nosql/quadstore.go:612

		return vt, nil
	}
	vs, ok := d[fldValData].(nosql.String)
	if !ok {
		return nil, fmt.Errorf("unknown value format: %T", d[fldValData])
	}
	if len(d) == 1 {
		return quad.String(vs), nil
	}
	if ok, _ := d[fldIRI].(nosql.Bool); ok {
		return quad.IRI(vs), nil
	} else if ok, _ := d[fldBNode].(nosql.Bool); ok {
		return quad.BNode(vs), nil
	} else if typ, ok := d[fldType].(nosql.String); ok {
		return quad.TypedString{Value: quad.String(vs), Type: quad.IRI(typ)}, nil
	} else if typ, ok := d[fldLang].(nosql.String); ok {
		return quad.LangString{Value: quad.String(vs), Lang: string(typ)}, nil
	}
	return nil, fmt.Errorf("unsupported value: %#v", d)
}

func (qs *QuadStore) Quad(val graph.Ref) (quad.Quad, error) {
	h := val.(QuadHash)
	var q quad.Quad
	var err error
	q.Subject, err = qs.NameOf(NodeHash(h.Get(quad.Subject)))
	if err != nil {
		return q, err
	}
	q.Predicate, err = qs.NameOf(NodeHash(h.Get(quad.Predicate)))
	if err != nil {
		return q, err
	}
	q.Object, err = qs.NameOf(NodeHash(h.Get(quad.Object)))
	if err != nil {
		return q, err
	}

View on GitHub (pinned to 81dcd7d73e)

Solutions

  1. Dump the document (%#v in the message) and check which discriminator keys are missing
  2. Re-import the original dataset into a fresh store
  3. Upgrade/downgrade Cayley so reader and writer versions match
  4. Report/patch if a new quad.Value kind was serialized but the reader predates it

Example fix

// before
q, err := qs.Quad(h)
// after: check document discriminators before conversion
if doc[fldIRI].(nosql.Bool) || doc[fldBNode].(nosql.Bool) {
    q, err = qs.Quad(h)
} else {
    return fmt.Errorf("unusable document %v", doc)
}
Defensive patterns

Strategy: type-guard

Validate before calling

_, hasIRI := doc["iri"].(nosql.Bool); _, hasBNode := doc["bnode"].(nosql.Bool); _, hasType := doc["type"].(nosql.String); _, hasLang := doc["lang"].(nosql.String)
if !hasIRI && !hasBNode && !hasType && !hasLang { return fmt.Errorf("unusable document %v", doc) }

Type guard

func knownValueKind(d map[string]interface{}) bool {
    if b, ok := d[fldIRI].(nosql.Bool); ok && bool(b) { return true }
    if b, ok := d[fldBNode].(nosql.Bool); ok && bool(b) { return true }
    _, ok := d[fldType].(nosql.String); if ok { return true }
    _, ok = d[fldLang].(nosql.String); return ok
}

Try / catch

q, err := qs.Quad(h)
if err != nil {
    log.Warnf("cannot decode quad %v: %v", h, err)
    continue
}

Prevention

When it happens

Trigger: 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.

Common situations: Store corruption, partial writes interrupted mid-commit, or documents produced by an incompatible writer version.

Understand the failure class

Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.

Related errors


AI-assisted analysis of cayleygraph/cayley@81dcd7d73e (2026-09-06). Data as JSON: /api/errors/80dfe6e03f7aa714. Report an issue: GitHub.