Skip to content

Comments

[AI] Nullable support in structured output and more integration tests#15752

Merged
andrewheard merged 9 commits intoai-structured-outputfrom
pb-structured-output-tests-and-fixes
Jan 23, 2026
Merged

[AI] Nullable support in structured output and more integration tests#15752
andrewheard merged 9 commits intoai-structured-outputfrom
pb-structured-output-tests-and-fixes

Conversation

@paulb777
Copy link
Member

@paulb777 paulb777 commented Jan 23, 2026

  1. New Integration Tests: Added comprehensive integration tests in SchemaTests.swift covering:
    • Boolean properties.
    • Optional properties.
    • String enumerations (.enumeration).
    • Array element constraints.
    • Multi-level nesting.
    • Decimal support.
    • Empty collections and specific counts.
    • Combined guides (.minimum, .maximum).
    • Error handling for incorrect types and missing fields.
  2. FirebaseGenerable.swift Updates:
    • Added ConvertibleFromModelOutput conformance to Optional to handle .null values gracefully.
  3. ModelOutput.swift Updates:
    • Updated value(_:forProperty:) to return nil when the property value is .null, ensuring optional properties are handled correctly even if the key is present but null.

@gemini-code-assist
Copy link
Contributor

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

@danger-firebase-ios
Copy link

1 Warning
⚠️ Did you forget to add a changelog entry? (Add #no-changelog to the PR description to silence this warning.)

Generated by 🚫 Danger

@paulb777
Copy link
Member Author

/gemini review

@paulb777 paulb777 changed the title [AI] Decimal and optional support for structured output; integration tests [AI] Optional support for structured output and more integration tests Jan 23, 2026
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for Decimal and optional types within the structured output functionality. The core logic changes in FirebaseGenerable.swift, ModelOutput.swift, and FirebaseGenerableMacro.swift are well-implemented to handle nullable values and Decimal types correctly. A comprehensive set of integration tests has been added in SchemaTests.swift, which is great for ensuring the robustness of these new features. My review focuses on a couple of minor corrections in the new test code to fix a compilation issue and improve clarity.

@paulb777 paulb777 changed the title [AI] Optional support for structured output and more integration tests [AI] Optional support in structured output and more integration tests Jan 23, 2026
@paulb777
Copy link
Member Author

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for optional properties in structured output, a valuable enhancement for flexibility. The implementation across FirebaseGenerable, ModelOutput, and the FirebaseGenerableMacro appears correct and well-integrated. A significant portion of this PR is the addition of numerous integration tests, which greatly improve the test coverage for structured output generation. These tests cover a wide variety of types and constraints. My main feedback relates to improving the precision validation in tests involving Decimal types to make them more robust.

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@paulb777
Copy link
Member Author

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request effectively adds support for optional properties in structured output and significantly expands the integration test suite. The changes to FirebaseGenerable.swift, ModelOutput.swift, and FirebaseGenerableMacro.swift correctly handle optional types and null values from the model. The new integration tests in SchemaTests.swift are comprehensive, covering various data types, constraints, and error scenarios, which greatly improves confidence in the structured output feature. I have one suggestion to improve the maintainability of the new test code by reducing duplication, and a couple of minor formatting suggestions.

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@paulb777 paulb777 marked this pull request as ready for review January 23, 2026 02:11
@paulb777 paulb777 requested a review from a team as a code owner January 23, 2026 02:11
@paulb777 paulb777 requested a review from andrewheard January 23, 2026 02:11
@andrewheard andrewheard changed the title [AI] Optional support in structured output and more integration tests [AI] Nullable support in structured output and more integration tests Jan 23, 2026
Copy link
Contributor

@andrewheard andrewheard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, Paul! The null handling was a good catch.

I reverted the optional handling for Partial since it already appears to be fixed by my upstream changes for Optional. I added an optional middleName property in the unit test to verify that it still gets expanded properly without it.

I'll merge if CI still passes since your new integration tests check both nullable and optional handling.

@andrewheard andrewheard merged commit a7d5c3e into ai-structured-output Jan 23, 2026
59 checks passed
@andrewheard andrewheard deleted the pb-structured-output-tests-and-fixes branch January 23, 2026 21:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants