Skip to content

.Net: [HB Planner] Content type fix#5133

Merged
teresaqhoang merged 6 commits intomicrosoft:mainfrom
teresaqhoang:json-fix
Feb 23, 2024
Merged

.Net: [HB Planner] Content type fix#5133
teresaqhoang merged 6 commits intomicrosoft:mainfrom
teresaqhoang:json-fix

Conversation

@teresaqhoang
Copy link
Contributor

Motivation and Context

Resolves #5127: If the Content-Type header of a REST API JSON response includes a charset (e.g. Content-Type: application/json; charset=utf-8), the Handlebars prompt template handles the response as a string instead of as deserialized JSON.

This PR changes the check from strict equality to a check that determine if the content type simply contains application/json

Contribution Checklist

@teresaqhoang teresaqhoang self-assigned this Feb 23, 2024
@teresaqhoang teresaqhoang requested a review from a team as a code owner February 23, 2024 20:17
@markwallace-microsoft markwallace-microsoft added .NET Issue or Pull requests regarding .NET code kernel Issues or pull requests impacting the core kernel labels Feb 23, 2024
@github-actions github-actions bot changed the title [HB Planner] Content type fix .Net: [HB Planner] Content type fix Feb 23, 2024
@teresaqhoang teresaqhoang added this pull request to the merge queue Feb 23, 2024
Merged via the queue into microsoft:main with commit d38b45d Feb 23, 2024
@teresaqhoang teresaqhoang deleted the json-fix branch February 23, 2024 20:47
LudoCorporateShark pushed a commit to LudoCorporateShark/semantic-kernel that referenced this pull request Aug 25, 2024
### Motivation and Context

<!-- Thank you for your contribution to the semantic-kernel repo!
Please help reviewers and future users, providing the following
information:
  1. Why is this change required?
  2. What problem does it solve?
  3. What scenario does it contribute to?
  4. If it fixes an open issue, please link to the issue here.
-->

Resolves microsoft#5127: If the Content-Type header of a REST API JSON response
includes a charset (e.g. Content-Type: application/json; charset=utf-8),
the Handlebars prompt template handles the response as a string instead
of as deserialized JSON.

This PR changes the check from strict equality to a check that determine
if the content type simply contains `application/json`

### Contribution Checklist

<!-- Before submitting this PR, please make sure: -->

- [x] The code builds clean without any errors or warnings
- [x] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [x] All unit tests pass, and I have added new tests where possible
- [x] I didn't break anyone 😄
Bryan-Roe pushed a commit to Bryan-Roe-ai/semantic-kernel that referenced this pull request Oct 6, 2024
### Motivation and Context

<!-- Thank you for your contribution to the semantic-kernel repo!
Please help reviewers and future users, providing the following
information:
  1. Why is this change required?
  2. What problem does it solve?
  3. What scenario does it contribute to?
  4. If it fixes an open issue, please link to the issue here.
-->

Resolves microsoft#5127: If the Content-Type header of a REST API JSON response
includes a charset (e.g. Content-Type: application/json; charset=utf-8),
the Handlebars prompt template handles the response as a string instead
of as deserialized JSON.

This PR changes the check from strict equality to a check that determine
if the content type simply contains `application/json`

### Contribution Checklist

<!-- Before submitting this PR, please make sure: -->

- [x] The code builds clean without any errors or warnings
- [x] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [x] All unit tests pass, and I have added new tests where possible
- [x] I didn't break anyone 😄
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kernel Issues or pull requests impacting the core kernel .NET Issue or Pull requests regarding .NET code

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

.Net: Handlebars prompt template doesn't deserialize JSON response when Content-Type includes charset

5 participants