Azure / Azure/azure-functions-host
Improve the Utility.IsJson binding helper
- Dominant language
- C#
- Stars
- 2k
- Forks
- 482
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 38
Description
The longstanding code we have [here](https://github.com/Azure/azure-functions-host/blob/d9f04cf7b55133fafeff4cc0dd9a5db9f1c65373/src/WebJobs.Script/Binding/FunctionBinding.cs#L115) in the binding pipeline for OOP for "sniffing" for JSON can lead to false positives and incorrect behavior. For example, for a string like `{ Hello, world }` it'll treat it as JSON.
The code should be modified to use a TryParse like approach (though Newtonsoft doesn’t have a TryParse which is why this helper exists). We need to be sure any changes we make here aren't breaking.
This came up recently in a PowerShell Functions case. Must be a pretty rare pattern, because this code has been in place for ages, and we haven't received any complaints on it until now.
Contributor guide
Research direction
Start with the linked FunctionBinding.cs code and trace the Utility.IsJson helper used by the OOP binding pipeline. Review existing binding behavior and tests before changing the JSON check; done means strings such as { Hello, world } are not classified as JSON while valid JSON behavior remains unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100