Skip to content

Fix OpenApiJsonSchema array parsing (#62051) #62118

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 4, 2025
Merged

Conversation

BrennanConroy
Copy link
Member

@BrennanConroy BrennanConroy commented May 27, 2025

Backport of #62051

Fix OpenApiJsonSchema array parsing

Description

When using the MapOpenApi() endpoint with a custom json converter that outputs an array with a default value, the app would crash with a stack overflow. The issue was that we never advanced the Utf8JsonReader when calling a recursive function. So we'd end up looking at the same json value over and over until stack overflowing.

Fixes #62023

Customer Impact

App can crash when accessing the OpenApi endpoint.

Regression?

  • Yes
  • No

Risk

  • High
  • Medium
  • Low

Obvious bug once pointed out. Fixed missing test coverage.

Verification

  • Manual (required)
  • Automated

Packaging changes reviewed?

  • Yes
  • No
  • N/A

@BrennanConroy BrennanConroy added this to the 9.0.x milestone May 27, 2025
@BrennanConroy BrennanConroy requested review from captainsafia and a team as code owners May 27, 2025 18:39
@BrennanConroy BrennanConroy added Servicing-consider Shiproom approval is required for the issue feature-openapi labels May 27, 2025
@BrennanConroy BrennanConroy added Servicing-approved Shiproom has approved the issue and removed Servicing-consider Shiproom approval is required for the issue labels May 28, 2025
@sander1095
Copy link
Contributor

Hi @BrennanConroy ! Considering the main PR was merged last week, will this one be merged soon, too? :)

@wtgodbe wtgodbe merged commit 1067210 into release/9.0 Jun 4, 2025
23 of 25 checks passed
@wtgodbe wtgodbe deleted the brecon/openbp branch June 4, 2025 18:26
@dotnet-policy-service dotnet-policy-service bot modified the milestones: 9.0.x, 9.0.7 Jun 4, 2025
Copy link

@Arnab-Developer Arnab-Developer left a comment

Choose a reason for hiding this comment

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

I have a code refactor related question.

None = 1
}

public class EnumArrayTypeConverter : JsonConverter<EnumArrayType>
Copy link

@Arnab-Developer Arnab-Developer Jul 9, 2025

Choose a reason for hiding this comment

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

The EnumArrayTypeConverter and EnumObjectTypeConverter classes has been used only in the tests. Can we not make those classes as private?

Suggested change
public class EnumArrayTypeConverter : JsonConverter<EnumArrayType>
private class EnumArrayTypeConverter : JsonConverter<EnumArrayType>

}
}

public class EnumObjectTypeConverter : JsonConverter<EnumArrayType>
Copy link

@Arnab-Developer Arnab-Developer Jul 9, 2025

Choose a reason for hiding this comment

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

Suggested change
public class EnumObjectTypeConverter : JsonConverter<EnumArrayType>
private class EnumObjectTypeConverter : JsonConverter<EnumArrayType>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-openapi Servicing-approved Shiproom has approved the issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants