From 3b204c696456981a260a11a8b5266991737d04b7 Mon Sep 17 00:00:00 2001 From: dlee-bq Date: Sat, 24 Oct 2026 06:55:55 +0000 Subject: [PATCH] [BugFix] `openbb-core`: Handle FastAPI 0.155.0 Query json_schema_extra default of None (#7803) FastAPI 0.155.0 changed the default of Query(...).json_schema_extra from {} to None. ReferenceGenerator._get_function_signature_info copied that value and later called .pop() on it, which broke test_get_function_signature_info_with_query_default and test_get_function_signature_info_query_default_branch. CI installs the newest FastAPI because it does not install from uv.lock. Fall back to {}, as the Annotated branch of the same function already does. Also cover the unclosed-bracket fallbacks in docstring_generator (_matching_bracket returning -1 and _rewrite_optional_and_union returning the input unchanged), which no test reached since #7794. Co-authored-by: dlee-bq <325002271+dlee-bq@users.noreply.github.com> --- .../app/static/package_builder/reference_generator.py | 2 +- .../static/package_builder/test_docstring_generator_helpers.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/openbb_platform/core/openbb_core/app/static/package_builder/reference_generator.py b/openbb_platform/core/openbb_core/app/static/package_builder/reference_generator.py index cc0fc7bfd0f..283a9d7f121 100644 --- a/openbb_platform/core/openbb_core/app/static/package_builder/reference_generator.py +++ b/openbb_platform/core/openbb_core/app/static/package_builder/reference_generator.py @@ -602,7 +602,7 @@ class ReferenceGenerator: else str(param_type) ) description = default.description # type: ignore - json_extra = default.json_schema_extra # type: ignore + json_extra = default.json_schema_extra or {} # type: ignore has_default = hasattr(default, "default") and default.default not in [ Parameter.empty, PydanticUndefined, diff --git a/openbb_platform/core/tests/app/static/package_builder/test_docstring_generator_helpers.py b/openbb_platform/core/tests/app/static/package_builder/test_docstring_generator_helpers.py index 980fabc78ea..ff77867c589 100644 --- a/openbb_platform/core/tests/app/static/package_builder/test_docstring_generator_helpers.py +++ b/openbb_platform/core/tests/app/static/package_builder/test_docstring_generator_helpers.py @@ -1961,6 +1961,7 @@ def test_literal_choices_reads_bare_optional_and_non_literal_types(): ("list[typing.Optional[str]]", "list[str | None]"), ("", "str"), ("datetime.date", "date"), + ("typing.Optional[str", "Optional[str"), # Literal still collapses to str; duplicates still collapse ("typing.Optional[typing.Literal['a', 'b']]", "str | None"), ("typing.Union[typing.Literal['a'], typing.Literal['b']]", "str"),