-
Notifications
You must be signed in to change notification settings - Fork 804
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
Use System.Text.Json to deserialize health report response #975
Conversation
4c18681
to
d6040bb
Compare
Is it really necessary to change all those |
What do you mean better ? |
src/HealthChecks.UI/Core/HostedService/HealthCheckReportCollector.cs
Outdated
Show resolved
Hide resolved
It's not necessary, I updated it when I tested it. |
When Status in response is 404, using Newtonsoft Json this value is propagated to the UII, where it crashes in some places. |
So now the error will occur earlier? |
2a1b004
to
4316864
Compare
No, this behavior occurs only with Newtonsoft.Json. Now with System.Text.Json the string values like "0", "2" , "Healthy", "Healthy " are handled correctly, when value is e.g. 404 it throws exception. |
Are you sure? You use |
@carlosrecuero Are you OK to change all those launchsettings files? |
Integer in a string (like "0") will be fine and an integer as a number (like 0) will fail if allowIntegerValues is false. |
I know this has nothing to do with the proposed changes, but they are samples and I think it's good that they work in one click. Or I can submit another pull request for these changes. |
🤔 I didn't know. OK. Though "0"/"1" seems a bit weird and maybe I would prefer to forbid such "enum values". I'm fine to merge as is if @carlosrecuero approve. |
@carlosrecuero Merge as you see fit. I have no write access with this new account. |
So.... I merge it as is because I see no harm to have all those launchsettings files. |
What this PR does / why we need it:
Use System.Text.Json to deserialize health report response in HealthCheckReportCollector.cs.
See https://github.com/dotnet/runtime/blob/main/src/libraries/System.Net.Http.Json/src/System/Net/Http/Json/HttpContentJsonExtensions.cs
Which issue(s) this PR fixes:
Better handling of bad responses
Please reference the issue this PR will close:
#[862]
Special notes for your reviewer:
Or it can be like this, but there is check for EnsureSuccessStatusCode() which fails for unhealthy status (returns 503), so I think this is not the right solution:
See https://github.com/dotnet/runtime/blob/main/src/libraries/System.Net.Http.Json/src/System/Net/Http/Json/HttpClientJsonExtensions.Get.cs
Does this PR introduce a user-facing change?:
No
Please make sure you've completed the relevant tasks for this PR, out of the following list: