{"record":{"id":"1bbd9639925d0ab7","repo":"openai/openai-python","slug":"received-positional-arguments-which-are-not-suppor","errorCode":null,"errorMessage":"Received positional arguments which are not supported; Keyword arguments must be used instead","messagePattern":"Received positional arguments which are not supported; Keyword arguments must be used instead","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"src/openai/_models.py","lineNumber":572,"sourceCode":"\n\ndef build(\n    base_model_cls: Callable[P, _BaseModelT],\n    *args: P.args,\n    **kwargs: P.kwargs,\n) -> _BaseModelT:\n    \"\"\"Construct a BaseModel class without validation.\n\n    This is useful for cases where you need to instantiate a `BaseModel`\n    from an API response as this provides type-safe params which isn't supported\n    by helpers like `construct_type()`.\n\n    ```py\n    build(MyModel, my_field_a=\"foo\", my_field_b=123)\n    ```\n    \"\"\"\n    if args:\n        raise TypeError(\n            \"Received positional arguments which are not supported; Keyword arguments must be used instead\",\n        )\n\n    return cast(_BaseModelT, construct_type(type_=base_model_cls, value=kwargs))\n\n\ndef construct_type_unchecked(*, value: object, type_: type[_T]) -> _T:\n    \"\"\"Loose coercion to the expected type with construction of nested values.\n\n    Note: the returned value from this function is not guaranteed to match the\n    given type.\n    \"\"\"\n    return cast(_T, construct_type(value=value, type_=type_))\n\n\ndef construct_type(*, value: object, type_: object, metadata: Optional[List[Any]] = None) -> object:\n    \"\"\"Loose coercion to the expected type with construction of nested values.\n","sourceCodeStart":554,"sourceCodeEnd":590,"githubUrl":"https://github.com/openai/openai-python/blob/9917c6e28e66e90e1227b3d223c06a8c5441515a/src/openai/_models.py#L554-L590","documentation":"The build() helper constructs a Pydantic model instance from keyword arguments only. Passing any positional argument is rejected because the SDK cannot reliably map positional values to model fields across schema variations, so it forces explicit keyword usage to avoid silent mis-binding.","triggerScenarios":"Calling openai._models.build(MyModel, 'foo', 123) or forwarding *args into build(); any call where the args tuple is non-empty.","commonSituations":"Copy-pasting pydantic-style MyModel('foo', 123) construction into SDK helper usage; programmatic argument forwarding that accidentally includes positionals.","solutions":["Pass every field as a keyword argument: build(MyModel, my_field_a='foo', my_field_b=123)","If forwarding dynamic args, unpack them as **kwargs instead of *args"],"exampleFix":"// before\nbuild(MyModel, \"foo\", 123)\n// after\nbuild(MyModel, my_field_a=\"foo\", my_field_b=123)","handlingStrategy":"validation","validationCode":"def safe_build(model, *args, **kwargs):\n    if args:\n        raise TypeError(f\"{model.__name__} requires keyword arguments: {args}\")\n    return build(model, **kwargs)","typeGuard":"def uses_only_kwargs(fn, *args, **kwargs) -> bool:\n    return not args","tryCatchPattern":null,"preventionTips":["Always call build()/construct helpers with explicit keyword arguments","Lint dynamic call sites that forward *args into SDK model helpers"],"tags":["python","validation","constructor","keyword-args"],"backgroundTag":"positional-args-not-allowed","analyzedSha":"9917c6e28e66e90e1227b3d223c06a8c5441515a","analyzedAt":"2026-08-28T11:46:34.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}