cocoindex-io/cocoindex · error · ValueError

Unknown memo_key parameter(s) for {qualified_name(fn)}(): {'

Error message

Unknown memo_key parameter(s) for {qualified_name(fn)}(): {', '.join(unknown)}

What it means

At decorator construction, memo_key parameter names are validated against the function's signature. Naming a parameter that the function doesn't declare raises ValueError, catching typos before any call happens.

Source

Thrown at python/cocoindex/_internal/function.py:539

    return final_args, new_kwargs


def _normalize_memo_key(
    fn: Callable[..., Any], memo_key: MemoKeySpec
) -> PreparedMemoKeySpec | None:
    """Validate and compile per-parameter memo-key overrides once."""
    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,

View on GitHub (pinned to e84aa99b32)

Solutions

  1. Correct the memo_key key to match an actual parameter of the function
  2. Check inspect.signature(fn) / the function definition for exact parameter names
  3. Remove memo_key entries for parameters that no longer exist after a rename

Example fix

# before
@coco.fn(memo_key={"parma": None})
async def f(param: str): ...

# after
@coco.fn(memo_key={"param": None})
async def f(param: str): ...
Defensive patterns

Strategy: validation

Validate before calling

import inspect
bad = set(memo_key) - set(inspect.signature(fn).parameters)
assert not bad, f"unknown memo_key params: {bad}"

Prevention

When it happens

Trigger: @coco.fn(memo_key={"parma": None}) or any misspelled/nonexistent parameter name in the memo_key mapping for the decorated function.

Common situations: Typos in memo_key keys; renaming function parameters without updating memo_key; copying memo_key specs between similar functions with different parameter names.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of cocoindex-io/cocoindex@e84aa99b32 (2026-09-08). Data as JSON: /api/errors/3fb637309fca3c8f. Report an issue: GitHub.