go-delve/delve · error

not hashable

Error message

not hashable

What it means

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.

Source

Thrown at pkg/terminal/starbind/conv.go:756

}

func (tgt starlarkTargetObject) Attr(name string) (starlark.Value, error) {
	env := tgt.env
	v, err := env.ctx.Client().EvalVariable(env.ctx.Scope(), name, env.ctx.LoadConfig())
	if err != nil {
		return starlark.None, fmt.Errorf("could not find variable %q: %v", name, err)
	}
	return env.variableValueToStarlarkValue(v, true)
}

type starlarkUnhashable struct {
}

func (starlarkUnhashable) Freeze() {
}

func (starlarkUnhashable) Hash() (uint32, error) {
	return 0, errors.New("not hashable")
}

View on GitHub (pinned to a23773e6c3)

Solutions

  1. Use only hashable Starlark types (strings, ints, bools, tuples of hashables) as dict keys; convert variable values with str() first.
  2. Avoid placing dlv-returned values directly in dicts or sets; store them in lists or under string keys.
  3. Check the value's type before hashing, e.g. `if type(v) == "string": d[v] = ...`.

Example fix

// before
d = {}
d[var_value] = "seen"  # error: not hashable
// after
d = {}
d[str(var_value)] = "seen"
Defensive patterns

Strategy: type-guard

Validate before calling

def is_hashable(v):
    try:
        hash(v)
        return True
    except Exception:
        return False

Type guard

def is_hashable(v):
    return type(v) in ("string", "int", "float", "bool", "NoneType") or type(v) == "tuple"

Try / catch

try:
    d[key] = value
except Exception as e:
    if "not hashable" in str(e):
        d[str(key)] = value  # fall back to string key
    else:
        raise

Prevention

When it happens

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

Common situations: 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.

Related errors


AI-assisted analysis of go-delve/delve@a23773e6c3 (2026-08-31). Data as JSON: /api/errors/16b0bdeae839940d. Report an issue: GitHub.