Skip to content

CreateRequest Method Should Call uri.AppendQuery if Path uri starts with "?" Query Separator #9958

@jorgerangel-msft

Description

@jorgerangel-msft

Consider this operation:

  @put
  @sharedRoute
  @route("?comp=copy")
  abortCopyFromUrl is StorageOperationNoBody<
    {
      ...TimeoutParameter;

      /** The copy identifier provided in the x-ms-copy-id header of the original Copy Blob operation. */
      @clientName("copyId")
      @query
      copyid: string;

      ...LeaseIdOptionalParameter;

      /** The copy action to be performed. */
      @header("x-ms-copy-action")
      copyActionAbortConstant: "abort";
    },
    {
      @statusCode statusCode: 204;
    }
  >;

The route contains a query string and the request body accepts a query. This results in the generated CreateRequest method for this operation to use

 uri.AppendPath("?comp=copy", false);
 uri.AppendQuery("copyid", copyId, true);

instead of calling AppendQuery

uri.AppendQuery("comp", "copy", true);
 uri.AppendQuery("copyid", copyId, true);

Which is leading to a possibly malformed uri ?comp=copy?copyid=6808d511-671f-47f0-b909-abe739c65139>.
We should correctly parse the route and call the correct UriBuilder APIs for each component of the string.

Metadata

Metadata

Labels

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

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions