Skip to content

[TCGC] Fix File type contentType/accept header inconsistencies#4030

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/fix-inconsistency-file-support
Draft

[TCGC] Fix File type contentType/accept header inconsistencies#4030
Copilot wants to merge 3 commits intomainfrom
copilot/fix-inconsistency-file-support

Conversation

Copy link
Contributor

Copilot AI commented Mar 11, 2026

Three bugs in File type handling: (1) contentType param typed as string instead of constant for File uploads with specific content types, (2) response contentType header has serializedName: undefined, (3) accept param is string instead of enum for multi-content-type downloads.

Changes

  • contentType constant for File uploads: createContentTypeOrAcceptHeader now checks bodyKind === "file" to treat File-specific content types (e.g. image/png) as constants, not just the hardcoded json/text/octet-stream set
  • Response header serializedName fallback: Added fallback in getSdkHttpResponseAndExceptions — when getHeaderFieldName returns undefined (File's contentTypeProperty lacks @header), maps to "Content-Type"
  • Enum accept for multiple content types: When accept has multiple content types, creates an anonymous SdkEnumType with values instead of defaulting to string
// Issue 1: contentType was string, now constant
op upload(@body file: File<"image/png">): void;

// Issue 2: response contentType header serializedName was undefined
op download(): File<"application/json", string>;

// Issue 3: accept was string, now enum with two values
op downloadMultiple(): File<"image/png" | "image/jpeg">;
Original prompt

This section details on the original issue you should resolve

<issue_title>[TCGC] Inconsistency for File support</issue_title>
<issue_description>Building uploadFileSpecificContentType the sdkMethod.parameters includes param contentType as string when it should be a constant. note that it is constant kind in the TypeSpec.Http.File type.

Building downloadFileJsonContentType, in the sdkMethod.operation.responses array, the contentType response header has its serializedName set to undefined.

In downloadFileMultipleContentTypes, the accept header param has type string but I believe it should be the anonymous enum containing image/png and image/jpeg values</issue_description>

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


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

…erializedName for response headers, enum accept for multiple content types

Co-authored-by: tadelesh <1726438+tadelesh@users.noreply.github.com>
@microsoft-github-policy-service microsoft-github-policy-service bot added the lib:tcgc Issues for @azure-tools/typespec-client-generator-core library label Mar 11, 2026
Co-authored-by: tadelesh <1726438+tadelesh@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix inconsistency in File support parameters and responses [TCGC] Fix File type contentType/accept header inconsistencies Mar 11, 2026
@tadelesh tadelesh changed the base branch from release/march-2026 to main March 11, 2026 05:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lib:tcgc Issues for @azure-tools/typespec-client-generator-core library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[TCGC] Inconsistency for File support

2 participants