Skip to content

Conversation

eiriktsarpalis
Copy link
Member

@eiriktsarpalis eiriktsarpalis commented Sep 16, 2025

Fix #6676

Microsoft Reviewers: Open in CodeFlow

@eiriktsarpalis eiriktsarpalis requested a review from a team as a code owner September 16, 2025 12:13
@Copilot Copilot AI review requested due to automatic review settings September 16, 2025 12:13
@github-actions github-actions bot added the area-ai Microsoft.Extensions.AI libraries label Sep 16, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a bug in the JSON schema generation where MinLength/MaxLength/Length attributes were incorrectly mapped to minItems/maxItems instead of minLength/maxLength for nullable string properties.

Key Changes:

  • Fixed attribute mapping logic to properly handle nullable string types
  • Added a helper method to correctly identify string schema types in union types
  • Updated test expectations to reflect the correct JSON schema property names

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
AIJsonUtilities.Schema.Create.cs Implements the core fix by adding TryGetSchemaType helper method and updating attribute mapping logic
AIJsonUtilitiesTests.cs Updates existing test expectations and adds new test case for nullable string properties with length constraints

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@stephentoub
Copy link
Member

Thanks

@stephentoub stephentoub merged commit f04bd50 into dotnet:main Sep 16, 2025
7 checks passed
This was referenced Oct 14, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-ai Microsoft.Extensions.AI libraries

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AI: If string is nullable, data annotations maxLength turns to maxItems

2 participants