{"record":{"id":"b3f57463c4f7574f","repo":"openai/openai-python","slug":"missing-required-arguments-human-join-quote-arg","errorCode":null,"errorMessage":"Missing required arguments: {human_join([quote(arg) for arg in missing])}","messagePattern":"Missing required arguments: (.+?)","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"src/openai/_utils/_utils.py","lineNumber":297,"sourceCode":"                matches = all((param in given_params for param in variant))\n                if matches:\n                    break\n            else:  # no break\n                if len(variants) > 1:\n                    variations = human_join(\n                        [\"(\" + human_join([quote(arg) for arg in variant], final=\"and\") + \")\" for variant in variants]\n                    )\n                    msg = f\"Missing required arguments; Expected either {variations} arguments to be given\"\n                else:\n                    assert len(variants) > 0\n\n                    # TODO: this error message is not deterministic\n                    missing = list(set(variants[0]) - given_params)\n                    if len(missing) > 1:\n                        msg = f\"Missing required arguments: {human_join([quote(arg) for arg in missing])}\"\n                    else:\n                        msg = f\"Missing required argument: {quote(missing[0])}\"\n                raise TypeError(msg)\n            return func(*args, **kwargs)\n\n        return wrapper  # type: ignore\n\n    return inner\n\n\n_K = TypeVar(\"_K\")\n_V = TypeVar(\"_V\")\n\n\n@overload\ndef strip_not_given(obj: None) -> None: ...\n\n\n@overload\ndef strip_not_given(obj: Mapping[_K, _V | NotGiven]) -> dict[_K, _V]: ...\n","sourceCodeStart":279,"sourceCodeEnd":315,"githubUrl":"https://github.com/openai/openai-python/blob/9917c6e28e66e90e1227b3d223c06a8c5441515a/src/openai/_utils/_utils.py#L279-L315","documentation":"The same @required_args decorator verifies that all parameters required by at least one overload variant were supplied. When the intersection of provided args and each variant's required set is empty, it raises this TypeError listing the missing names (from the first variant). It reproduces pyright-style 'Missing required argument' errors at runtime for methods whose signatures the type checker cannot fully enforce.","triggerScenarios":"Calling an SDK method without one of its required kwargs, e.g. client.completions.create(model=\"gpt-4o\") without prompt/messages, or client.files.create(file=f) without purpose; conditional code paths that sometimes skip a required keyword.","commonSituations":"Config-driven request builders that conditionally include fields; refactoring that renamed a parameter; new SDK versions adding a required parameter; forgetting purpose on file uploads.","solutions":["Add the missing keyword argument named in the message","If fields are conditional, default them explicitly or branch so every call includes all required kwargs","Check the method's docstring/signature for required vs optional params after upgrades","Run pyright/mypy on call sites — these errors are statically detectable"],"exampleFix":"# before\nf = client.files.create(file=open(\"x.jsonl\",\"rb\"))\n\n# after\nf = client.files.create(file=open(\"x.jsonl\",\"rb\"), purpose=\"assistants\")","handlingStrategy":"validation","validationCode":"import inspect\nrequired = {n for n,p in inspect.signature(method).parameters.items() if p.default is inspect.Parameter.empty}\nmissing = required - provided\nassert not missing, f\"missing {missing}\"","typeGuard":"def required_args_satisfied(method, kwargs: dict) -> bool:\n    import inspect\n    req = {n for n,p in inspect.signature(method).parameters.items()\n           if p.default is inspect.Parameter.empty and p.kind in (p.POSITIONAL_OR_KEYWORD, p.KEYWORD_ONLY)}\n    return req <= set(kwargs) | {n for n,p in inspect.signature(method).parameters.items() if p.default is inspect.Parameter.empty} & set(kwargs) or bool(req & set(kwargs))","tryCatchPattern":"try:\n    method(**payload)\nexcept TypeError as e:\n    if \"required argument\" in str(e): collect_and_retry(payload)","preventionTips":["Run pyright/mypy on call sites","Add schema validation for config-built payloads","Re-read method docs after version upgrades"],"tags":["typeerror","required-args","overloads","api-usage"],"backgroundTag":"missing-required-argument","analyzedSha":"9917c6e28e66e90e1227b3d223c06a8c5441515a","analyzedAt":"2026-08-28T11:46:34.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}