{"record":{"id":"16b0bdeae839940d","repo":"go-delve/delve","slug":"not-hashable","errorCode":null,"errorMessage":"not hashable","messagePattern":"not hashable","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/terminal/starbind/conv.go","lineNumber":756,"sourceCode":"}\n\nfunc (tgt starlarkTargetObject) Attr(name string) (starlark.Value, error) {\n\tenv := tgt.env\n\tv, err := env.ctx.Client().EvalVariable(env.ctx.Scope(), name, env.ctx.LoadConfig())\n\tif err != nil {\n\t\treturn starlark.None, fmt.Errorf(\"could not find variable %q: %v\", name, err)\n\t}\n\treturn env.variableValueToStarlarkValue(v, true)\n}\n\ntype starlarkUnhashable struct {\n}\n\nfunc (starlarkUnhashable) Freeze() {\n}\n\nfunc (starlarkUnhashable) Hash() (uint32, error) {\n\treturn 0, errors.New(\"not hashable\")\n}\n","sourceCodeStart":738,"sourceCodeEnd":758,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/terminal/starbind/conv.go#L738-L758","documentation":"Delve's starlarkUnhashable placeholder type implements starlark.Value but its Hash() method always returns the error 'not hashable'. It is used for API values that cannot be mapped to a Starlark type; any attempt to use such a value as a Starlark dict key or set member calls Hash() and receives this error.","triggerScenarios":"In a Starlark script, using a value returned by a Delve binding that maps to starlarkUnhashable (unmappable/unloaded values) as a dictionary key, in a set, or in any hash-requiring context.","commonSituations":"Scripts building dicts keyed by variable values (e.g. grouping variables by value); comparing unmapped values in dict lookups; using complex/unsupported types as keys.","solutions":["Use only hashable Starlark types (strings, ints, bools, tuples of hashables) as dict keys; convert variable values with str() first.","Avoid placing dlv-returned values directly in dicts or sets; store them in lists or under string keys.","Check the value's type before hashing, e.g. `if type(v) == \"string\": d[v] = ...`."],"exampleFix":"// before\nd = {}\nd[var_value] = \"seen\"  # error: not hashable\n// after\nd = {}\nd[str(var_value)] = \"seen\"","handlingStrategy":"type-guard","validationCode":"def is_hashable(v):\n    try:\n        hash(v)\n        return True\n    except Exception:\n        return False","typeGuard":"def is_hashable(v):\n    return type(v) in (\"string\", \"int\", \"float\", \"bool\", \"NoneType\") or type(v) == \"tuple\"","tryCatchPattern":"try:\n    d[key] = value\nexcept Exception as e:\n    if \"not hashable\" in str(e):\n        d[str(key)] = value  # fall back to string key\n    else:\n        raise","preventionTips":["Use str() on variable values before using them as dict keys","Keep dict keys to primitive Starlark types (string/int/bool/tuple)","Never store dlv-returned values directly as keys"],"tags":["starlark","scripting","hashability"],"backgroundTag":"unhashable-type","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}