cocoindex-io/cocoindex · error · TypeError
Unknown memo_key parameter(s) for {qualified_name(fn)}(): {u
Error message
Unknown memo_key parameter(s) for {qualified_name(fn)}(): {unknown} What it means
This is a near-duplicate of the _normalize_memo_key ValueError but raised from a later diagnostic path in the same validation, with the unknown names formatted via a single interpolated value. It fires when memo_key references parameters absent from the decorated function's signature.
Source
Thrown at python/cocoindex/_internal/function.py:546
if memo_key is None:
return None
normalized = dict(memo_key)
if not normalized:
return None
sig = inspect.signature(fn)
param_names = {param.name for param in sig.parameters.values()}
unknown = sorted(name for name in normalized if name not in param_names)
if unknown:
raise ValueError(
f"Unknown memo_key parameter(s) for {qualified_name(fn)}(): "
+ ", ".join(unknown)
)
for name, transform in normalized.items():
if transform is not None and not callable(transform):
raise TypeError(
f"memo_key[{name!r}] for {qualified_name(fn)}() must be a callable or None"
)
positional: list[MemoKeyTransform | None | NotSetType] = []
varargs_override: MemoKeyTransform | None | NotSetType = NOT_SET
varkw_override: MemoKeyTransform | None | NotSetType = NOT_SET
for param in sig.parameters.values():
if param.kind in (
inspect.Parameter.POSITIONAL_ONLY,
inspect.Parameter.POSITIONAL_OR_KEYWORD,
):
if param.name in normalized:
positional.append(normalized[param.name])
else:
positional.append(NOT_SET)
elif param.kind == inspect.Parameter.VAR_POSITIONAL:
if param.name in normalized:View on GitHub (pinned to e84aa99b32)
Solutions
- Fix the memo_key keys to match declared parameters
- Keep memo_key specs co-located with the function definition to catch drift in review
- Add a unit test decorating the function at import time so the ValueError surfaces early
Example fix
# before
@coco.fn(memo_key={"old_param": None})
async def f(new_param: str): ...
# after
@coco.fn(memo_key={"new_param": None})
async def f(new_param: str): ... Defensive patterns
Strategy: validation
Validate before calling
import inspect assert set(memo_key) <= set(inspect.signature(fn).parameters), "memo_key names must match fn parameters"
Prevention
- Reuse a shared helper to build memo_key specs per function
- Run a quick smoke import of decorated modules in CI
- Avoid sharing one memo_key dict across functions with different signatures
When it happens
Trigger: Same as error 37: @coco.fn(memo_key={...}) containing a name not in fn's parameters, reached via the alternate validation/reporting branch in _normalize_memo_key (called from __init__ and tests).
Common situations: Typos, stale parameter names after refactoring, or reused memo_key dicts across different functions.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- Unknown memo_key parameter(s) for {qualified_name(fn)}(): {'
- memo_key transform for *args must return tuple, got {type(va
- memo_key transform for **kwargs must return dict, got {type(
- deps= requires logic_tracking to be enabled; with logic_trac
- coco.use_state() cannot be called inside a memoized function
AI-assisted analysis of cocoindex-io/cocoindex@e84aa99b32 (2026-09-08).
Data as JSON: /api/errors/d07f59409839ed4b.
Report an issue: GitHub.