{"record":{"id":"133471062bc00d28","repo":"openai/openai-python","slug":"a-value-for-placeholder-name-was-not-provide","errorCode":null,"errorMessage":"a value for placeholder {{{name}}} was not provided","messagePattern":"a value for placeholder (.+?)\\}\\} was not provided","errorType":"validation","errorClass":"KeyError","httpStatus":null,"severity":"error","filePath":"src/openai/_utils/_path.py","lineNumber":66,"sourceCode":"    template: str,\n    values: Mapping[str, Any],\n    quoter: Callable[[str], str],\n) -> str:\n    \"\"\"Replace {name} placeholders in `template`, quoting each value with `quoter`.\n\n    Placeholder names are looked up in `values`.\n\n    Raises:\n        KeyError: If a placeholder is not found in `values`.\n    \"\"\"\n    # re.split with a capturing group returns alternating\n    # [text, name, text, name, ..., text] elements.\n    parts = _PLACEHOLDER_RE.split(template)\n\n    for i in range(1, len(parts), 2):\n        name = parts[i]\n        if name not in values:\n            raise KeyError(f\"a value for placeholder {{{name}}} was not provided\")\n        val = values[name]\n        if val is None:\n            parts[i] = \"null\"\n        elif isinstance(val, bool):\n            parts[i] = \"true\" if val else \"false\"\n        else:\n            parts[i] = quoter(str(values[name]))\n\n    return \"\".join(parts)\n\n\ndef path_template(template: str, /, **kwargs: Any) -> str:\n    \"\"\"Interpolate {name} placeholders in `template` from keyword arguments.\n\n    Args:\n        template: The template string containing {name} placeholders.\n        **kwargs: Keyword arguments to interpolate into the template.\n","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/openai/openai-python/blob/9917c6e28e66e90e1227b3d223c06a8c5441515a/src/openai/_utils/_path.py#L48-L84","documentation":"path_template builds URL paths from templates containing {placeholder} segments; _interpolate splits the template and requires a value in the provided kwargs mapping for every placeholder. This KeyError means a path parameter required by the method's URL template was not supplied — the SDK guarantees all placeholders are declared required, so in practice it fires when calling resource methods through reflection or with programmatically-built kwargs that omit a path parameter.","triggerScenarios":"Calling an endpoint method with a URL template like /resources/{id} without the corresponding keyword argument, or passing the value inside a body/extra kwargs object instead of as its own keyword; dynamic dispatch that forwards an incomplete kwargs dict.","commonSituations":"Generic wrappers that map HTTP verbs to SDK methods and drop path params; typos in the parameter name (value passed as obj_id instead of id); copy-pasted calls missing the id argument.","solutions":["Check the method signature and pass every path parameter as an explicit keyword argument","Fix typos: the kwargs key must exactly match the placeholder name in the URL template","If building calls dynamically, inspect the template's placeholders and assert your kwargs cover them before invoking","Catch KeyError to fail fast with a clearer message in reflection-based wrappers"],"exampleFix":"# before\nclient.resources.delete()  # missing id\n\n# after\nclient.resources.delete(\"res_123\")","handlingStrategy":"validation","validationCode":"import inspect, re\nparams = set(re.findall(r\"\\{(\\w+)\\}\", template))\nmissing = params - set(kwargs)\nassert not missing, f\"missing: {missing}\"","typeGuard":"def has_all_path_params(template: str, kwargs: dict) -> bool:\n    import re\n    return set(re.findall(r\"\\{(\\w+)\\}\", template)) <= set(kwargs)","tryCatchPattern":"try:\n    method(**kwargs)\nexcept KeyError as e:\n    raise ValueError(f\"call missing path param: {e}\") from e","preventionTips":["Pass path params as explicit keyword arguments","Prefer static calls over reflection for SDK methods","Lint for *args forwarding into SDK methods"],"tags":["keyerror","path-params","url-template","api-usage"],"backgroundTag":"missing-path-parameter","analyzedSha":"9917c6e28e66e90e1227b3d223c06a8c5441515a","analyzedAt":"2026-08-28T11:46:34.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}