Skip to content
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

HealthChecker fails to deserialize a valid JSON string #2287

Open
kikaragyozov opened this issue Aug 19, 2024 · 1 comment · May be fixed by #2340
Open

HealthChecker fails to deserialize a valid JSON string #2287

kikaragyozov opened this issue Aug 19, 2024 · 1 comment · May be fixed by #2340

Comments

@kikaragyozov
Copy link

kikaragyozov commented Aug 19, 2024

If you have written the following json string:

"{ \"msg\": \"Hello World!\\n\"}"

For a webhook's payload in your appsettings.json configuration file, the library will fail to deserialize it, whereas if you pass the above string to System.Text.Json.JsonSerializer, it will successfully parse it.

After debugging, the issue occurs here:

Payload = string.IsNullOrEmpty(item.Payload) ? new JsonObject() : JsonNode.Parse(Regex.Unescape(item.Payload))

The Regex.Unescape call turns the above into an invalid json string. Why are we escaping exactly?

Currently it's impossible to define a new line in the JSON webhook payload object, until the above is somehow addressed.

The exception is thrown when you go to the "Webhooks" section in the UI.

@JonathanNagy
Copy link

After figuring out webhooks this morning, the issue seems to be just in the UI. The actual webhook delivers properly with newlines, but the UI shows "Error fetching webhooks information" on the Webhooks tab.

JonathanNagy added a commit to JonathanNagy/AspNetCore.Diagnostics.HealthChecks that referenced this issue Dec 6, 2024
* Allow for escaped newlines inside double quoted blocks in payload when pulling the list of webhooks from the webhooks API
* Unit tests for newlines inside and outside quoted JSON strings in payload
@JonathanNagy JonathanNagy linked a pull request Dec 6, 2024 that will close this issue
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants