{"record":{"id":"ad7cc1c9f27f129a","repo":"cayleygraph/cayley","slug":"unexpected-type","errorCode":null,"errorMessage":"Unexpected type","messagePattern":"Unexpected type","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"query/linkedql/steps/properties.go","lineNumber":46,"sourceCode":"}\n\nfunc resolveNames(names *linkedql.PropertyPath) (linkedql.PropertyIRIs, error) {\n\tif names == nil {\n\t\treturn nil, fmt.Errorf(\"Not implemented: should tag all properties\")\n\t}\n\tswitch n := names.PropertyPathI.(type) {\n\tcase linkedql.PropertyStep:\n\t\treturn nil, fmt.Errorf(\"Not implemented: should use step to resolve to properties\")\n\tcase linkedql.PropertyIRIs:\n\t\treturn n, nil\n\tcase linkedql.PropertyIRIStrings:\n\t\treturn n.PropertyIRIs(), nil\n\tcase linkedql.PropertyIRI:\n\t\treturn linkedql.PropertyIRIs{n}, nil\n\tcase linkedql.PropertyIRIString:\n\t\treturn linkedql.PropertyIRIs{linkedql.PropertyIRI(n)}, nil\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"Unexpected type\")\n\t}\n}\n\n// BuildPath implements linkedql.PathStep.\nfunc (s *Properties) BuildPath(qs graph.QuadStore, ns *voc.Namespaces) (*path.Path, error) {\n\tfromPath, err := s.From.BuildPath(qs, ns)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tp := fromPath\n\tnames, err := resolveNames(s.Names)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tfor _, n := range names {\n\t\tname := quad.IRI(n).FullWith(ns)\n\t\ttag := string(name)\n\t\tp = p.Save(name, tag)","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/cayleygraph/cayley/blob/81dcd7d73e45136bc0d01802a8ba4685d8a533eb/query/linkedql/steps/properties.go#L28-L64","documentation":"The default branch of resolveNames in properties.go:46 throws this bare 'Unexpected type' error when the PropertyPath's concrete type is none of the four supported kinds (PropertyStep, PropertyIRIs, PropertyIRIStrings, PropertyIRI, PropertyIRIString). It means an unknown implementation of the PropertyPathI interface reached the Properties step.","triggerScenarios":"Passing a custom or unmarshalled value as Properties.Names whose underlying type does not match any known linkedql.PropertyPath implementation.","commonSituations":"Custom JSON unmarshalling that produced an unexpected concrete type (e.g. []interface{} or string instead of the typed wrappers), or third-party code implementing PropertyPathI with a new type.","solutions":["Use one of the supported wrappers: PropertyIRIs, PropertyIRIStrings, PropertyIRI, or PropertyIRIString.","Fix unmarshalling so Names decode into the correct linkedql types.","Log the %T of names.PropertyPathI to identify the offending type (wrap the error with type info for debugging).","Extend the switch if a new PropertyPath implementation was added intentionally."],"exampleFix":"// before\nNames: []interface{}{\"http://example.org/p\"} // untyped slice\n// after\nNames: linkedql.NewPropertyPath(linkedql.PropertyIRIStrings{\"http://example.org/p\"})","handlingStrategy":"type-guard","validationCode":"switch names.PropertyPathI.(type) {\ncase linkedql.PropertyIRIs, linkedql.PropertyIRIStrings, linkedql.PropertyIRI, linkedql.PropertyIRIString:\n  // ok\ndefault:\n  return fmt.Errorf(\"unsupported PropertyPath type %T\", names.PropertyPathI)\n}","typeGuard":"func isKnownPropertyPath(v interface{}) bool {\n  switch v.(type) {\n  case linkedql.PropertyIRIs, linkedql.PropertyIRIStrings, linkedql.PropertyIRI, linkedql.PropertyIRIString, linkedql.PropertyStep:\n    return true\n  }\n  return false\n}","tryCatchPattern":"p, err := step.BuildPath(qs, ns)\nif err != nil {\n  if err.Error() == \"Unexpected type\" {\n    return fmt.Errorf(\"Properties.Names has unsupported type %T\", step.Names)\n  }\n  return err\n}","preventionTips":["Decode Names with typed custom unmarshalling into linkedql wrappers","Never assign raw []interface{} or string to Names","Wrap the bare error with type info at call sites for debuggability"],"tags":["linkedql","type-mismatch","go"],"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"}