{"record":{"id":"1ea7cdbc3b16c9d9","repo":"openai/openai-python","slug":"warnings-is-only-supported-in-pydantic-v2","errorCode":null,"errorMessage":"warnings is only supported in Pydantic v2","messagePattern":"warnings is only supported in Pydantic v2","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/openai/_models.py","lineNumber":353,"sourceCode":"                exclude_computed_fields: Whether to exclude computed fields.\n                    While this can be useful for round-tripping, it is usually recommended to use the dedicated\n                    `round_trip` parameter instead.\n                round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].\n                warnings: How to handle serialization errors. False/\"none\" ignores them, True/\"warn\" logs errors,\n                    \"error\" raises a [`PydanticSerializationError`][pydantic_core.PydanticSerializationError].\n                fallback: A function to call when an unknown value is encountered. If not provided,\n                    a [`PydanticSerializationError`][pydantic_core.PydanticSerializationError] error is raised.\n                serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.\n\n            Returns:\n                A dictionary representation of the model.\n            \"\"\"\n            if mode not in {\"json\", \"python\"}:\n                raise ValueError(\"mode must be either 'json' or 'python'\")\n            if round_trip != False:\n                raise ValueError(\"round_trip is only supported in Pydantic v2\")\n            if warnings != True:\n                raise ValueError(\"warnings is only supported in Pydantic v2\")\n            if context is not None:\n                raise ValueError(\"context is only supported in Pydantic v2\")\n            if serialize_as_any != False:\n                raise ValueError(\"serialize_as_any is only supported in Pydantic v2\")\n            if fallback is not None:\n                raise ValueError(\"fallback is only supported in Pydantic v2\")\n            if exclude_computed_fields != False:\n                raise ValueError(\"exclude_computed_fields is only supported in Pydantic v2\")\n            dumped = super().dict(  # pyright: ignore[reportDeprecated]\n                include=include,\n                exclude=exclude,\n                by_alias=by_alias if by_alias is not None else False,\n                exclude_unset=exclude_unset,\n                exclude_defaults=exclude_defaults,\n                exclude_none=exclude_none,\n            )\n\n            return cast(\"dict[str, Any]\", json_safe(dumped)) if mode == \"json\" else dumped","sourceCodeStart":335,"sourceCodeEnd":371,"githubUrl":"https://github.com/openai/openai-python/blob/9917c6e28e66e90e1227b3d223c06a8c5441515a/src/openai/_models.py#L335-L371","documentation":"In the Pydantic v1 compat shim for model_dump, the warnings keyword is accepted only at its default (True); passing warnings=False — the common Pydantic v2 usage to silence serialization warnings — is unsupported and raises ValueError.","triggerScenarios":"Calling model.model_dump(warnings=False) on SDK models under Pydantic v1.","commonSituations":"Suppressing Pydantic v2 serialization warnings by porting warnings=False into a project still on Pydantic v1.","solutions":["Drop warnings=False under Pydantic v1","Upgrade to pydantic>=2 where warnings=False is honored"],"exampleFix":"# before\nd = obj.model_dump(warnings=False)\n# after\nd = obj.model_dump()\n","handlingStrategy":"validation","validationCode":"import pydantic\nif pydantic.VERSION.startswith('1.'):\n    kwargs.pop('warnings', None)\nobj.model_dump(**kwargs)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Under pydantic v1, filter warnings via the warnings module instead of warnings=False"],"tags":["pydantic","serialization","v1-compat","models"],"backgroundTag":"pydantic-version-mismatch","analyzedSha":"9917c6e28e66e90e1227b3d223c06a8c5441515a","analyzedAt":"2026-08-28T11:46:34.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}