Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 30, 2026

  • Understand the issue: The previous fix in PR Fix optional Content-Type headers being transformed to enums (emitter-only) #9495 added Content-Type header detection in type-converter.ts, but it relies on sdkProperty being passed to fromSdkType. The fromHeaderParameter function in operation-converter.ts doesn't pass the header parameter to fromSdkType, so the fix doesn't work.
  • Fix fromHeaderParameter to pass the header parameter p to fromSdkType so the Content-Type detection can work
  • Unify all parameter-processing functions to pass property instance to fromSdkType:
    • fromQueryParameter
    • fromPathParameter
    • fromHeaderParameter
    • fromBodyParameter
    • updateMethodParameter
  • Investigated making sdkProperty required - not feasible as many callers have no property context (model base types, array/dict value types, etc.)
  • Run existing tests to verify the fix works (all 177 tests pass)
  • Fix CI formatting issues
  • Run code review and security checks
Original prompt

This section details on the original issue you should resolve

<issue_title>Fix optional contentType issue</issue_title>
<issue_description>As described in Azure/azure-sdk-for-net#55300, but the issue belongs in this repo.</issue_description>

<agent_instructions>The previous fix does not really fix the issue entirely.
Please fix this again following the root cause in this comment: #9494 (comment)</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@ArcturusZhang I think this is not fixed. The fix introduced an extra check to see if it is a content type header, by checking if the `sdkProperty` is not undefined, but in our code, when the `fromSdkType` is called converting the method parameters (for instance [here](https://github.com/microsoft/typespec/blob/f1a7649b3b53ab7d30488cf7274f813696cdf2d0/packages/http-client-csharp/emitter/src/lib/operation-converter.ts#L482)), the `sdkProperty` argument is never passed in. Therefore the fix is not actually running.

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…Type

Co-authored-by: ArcturusZhang <10554446+ArcturusZhang@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix optional contentType issue in the SDK Fix optional Content-Type header detection in fromHeaderParameter Jan 30, 2026
@microsoft-github-policy-service microsoft-github-policy-service bot added the emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp label Jan 30, 2026
Copilot AI requested a review from ArcturusZhang January 30, 2026 08:42
Co-authored-by: ArcturusZhang <10554446+ArcturusZhang@users.noreply.github.com>
Copilot AI changed the title Fix optional Content-Type header detection in fromHeaderParameter Fix optional Content-Type header detection by unifying parameter processing Jan 30, 2026
Copilot AI requested a review from ArcturusZhang January 30, 2026 08:54
@ArcturusZhang ArcturusZhang marked this pull request as ready for review January 30, 2026 08:56
@ArcturusZhang
Copy link
Member

@copilot please fix the CI issues.

Co-authored-by: ArcturusZhang <10554446+ArcturusZhang@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 30, 2026

@copilot please fix the CI issues.

Fixed the formatting issue in 43ba7df. The CI was failing because of a long line that needed to be broken into multiple lines.

@JoshLove-msft JoshLove-msft added this pull request to the merge queue Jan 30, 2026
Merged via the queue into main with commit 9099825 Jan 30, 2026
23 checks passed
@JoshLove-msft JoshLove-msft deleted the copilot/fix-optional-contenttype-issue branch January 30, 2026 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix optional contentType issue

3 participants