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

[Bug]: Using HttpPart results in error in emitter-server-js #6787

Open
4 tasks done
experimentlife opened this issue Mar 31, 2025 · 0 comments
Open
4 tasks done

[Bug]: Using HttpPart results in error in emitter-server-js #6787

experimentlife opened this issue Mar 31, 2025 · 0 comments
Assignees
Labels
Milestone

Comments

@experimentlife
Copy link

experimentlife commented Mar 31, 2025

Describe the bug

import "@typespec/http";

using Http;

@error
model Error<T extends string> {
  code: T;
  message: string;
  details?: Record<string>;
  timestamp: utcDateTime;
}

/**
 * Standard success response
 */
model Result<T extends string> {
  code: T;
  message: string;
  details?: Record<string>;
  timestamp: utcDateTime;
}

model AttachmentError is Error<"invalid-attachment" | "empty-attachment">;
model AttachmentResult is Result<"added-attachment">;

interface x {
@route("{id}/addAttachment") @post addAttachment(@path id: string, @header contentType: "multipart/form-data", 
    @multipartBody body: {
      recepientRequestId: HttpPart<string>;
      name: HttpPart<string>;
      type: HttpPart<string>;
      data: HttpPart<File>;
    },) : AttachmentError | AttachmentResult;
}

Image

The above when using a HttpPart results in

Emitter "@typespec/http-server-js" crashed! This is a bug.
Please file an issue at https://github.com/microsoft/typespec/issues

Error: UNREACHABLE: HttpPart must have a Model argument
    at emitWellKnownModel (file:///C:/r/prod/pserv/PServAgentService/node_modules/@typespec/http-server-js/dist/src/common/model.js:105:23)
    at emitTypeReference (file:///C:/r/prod/pserv/PServAgentService/node_modules/@typespec/http-server-js/dist/src/common/reference.js:55:24)
    at emitModel (file:///C:/r/prod/pserv/PServAgentService/node_modules/@typespec/http-server-js/dist/src/common/model.js:47:31)
    at emitModel.next (<anonymous>)
    at emitDeclaration (file:///C:/r/prod/pserv/PServAgentService/node_modules/@typespec/http-server-js/dist/src/common/declaration.js:21:20)
    at emitDeclaration.next (<anonymous>)
    at completePendingDeclarations (file:///C:/r/prod/pserv/PServAgentService/node_modules/@typespec/http-server-js/dist/src/ctx.js:111:28)
    at emitRawServerOperation (file:///C:/r/prod/pserv/PServAgentService/node_modules/@typespec/http-server-js/dist/src/http/server/index.js:67:5)
    at emitRawServerOperation.next (<anonymous>)
    at emitRawServer (file:///C:/r/prod/pserv/PServAgentService/node_modules/@typespec/http-server-js/dist/src/http/server/index.js:44:16)

--------------------------------------------------
Library Version                0.58.0-alpha.11
TypeSpec Compiler Version      0.67.2
--------------------------------------------------

Reproduction

Run the sample provided above in the description

Checklist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants