Repository navigation
build(server): ban the HTTP JSON helpers that serialize by reflection - #556
Merged
Merged
Conversation
… (CHK-65) The Server and the BFF ban the JsonContent, HttpClient, HttpContent, HttpRequest, HttpResponse, Results, and TypedResults JSON overloads that take no JsonTypeInfo or context. The BFF problem body now writes through ManagementProblemJson, with the same bytes as before.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The Server and the BFF now ban, with RS0030, the HTTP JSON helpers that serialize by reflection: the overloads of
JsonContent.Create, theHttpClientJSON calls,ReadFromJsonAsync,WriteAsJsonAsync,Results.Json, andTypedResults.Jsonthat take noJsonTypeInfoor context. Each message names the fix: pass aJsonTypeInfofrom a[JsonSerializable]context.BannedSymbols.txt.ManagementProblem.csnow writes through aManagementProblemJsoncontext. The 8 refusal bodies are byte-for-byte the same as before.Why
An agent eval on a model provider task showed that agents copy reflection JSON from existing code, and no check caught it. The rule is in
docs/backend/source-generators.md.Test plan
dotnet build FullstackTemplate.slnx: 0 warnings, 0 errorsJsonContent.Create(new { ... })fails the build with RS0030 in the Server and in the BFFtests/FullstackTemplate.Bff.Tests: 575 of 575 pass