cayleygraph/cayley · error

Expected %v to be a string but instead received %T

Error message

Expected %v to be a string but instead received %T

What it means

Error "Expected %v to be a string but instead received %T" thrown in cayleygraph/cayley.

Source

Thrown at query/linkedql/steps/jsonld_util.go:40

	a, ok := i.(ldArray)
	if ok && len(a) == 1 {
		return a[0]
	}
	return i
}

// isomorphic checks whether source and target JSON-LD structures are the same
// semantically. This function is not complete and is maintained for testing
// purposes. Hopefully in the future it can be proven sufficient for general
// purpose use.
func isomorphic(source interface{}, target interface{}) error {
	source = unwrapValue(unwrapSingle(source))
	target = unwrapValue(unwrapSingle(target))
	switch s := source.(type) {
	case string:
		t, ok := target.(string)
		if !ok {
			return fmt.Errorf("Expected %v to be a string but instead received %T", target, target)
		}
		if s != t {
			return fmt.Errorf("Expected \"%v\" but instead received \"%v\"", s, t)
		}
		return nil
	case ldArray:
		t, ok := target.(ldArray)
		if !ok {
			return fmt.Errorf("Expected multiple values but instead received the single value: %#v", target)
		}
		if len(s) != len(t) {
			return fmt.Errorf("Expected %#v and %#v to have the same length", s, t)
		}
	items:
		for _, i := range s {
			for _, tI := range t {
				if isomorphic(i, tI) == nil {
					continue items

View on GitHub (pinned to 81dcd7d73e)

When it happens

Trigger: Thrown at query/linkedql/steps/jsonld_util.go:40 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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