OData / OData/AspNetCoreOData

Batch request fails with encoded URL

Open
#1,009 3 comments 1 reaction 1 assignee View on GitHub

@xuzhg is already working on this.

Since Aug 8, 2023.

bug
Dominant language
C#
Stars
505
Forks
186
PR merge metrics
No merged PRs in 30d

Description

Assemblies affected
ASP.NET Core OData 8.x

Describe the bug
When using multipart/mixed batch requests, with encoded URL in the batch request body (i.e., ' is encoded to %27). However, this causes an Internal Server Error (HTTP 500) in ASP.NET Core 7 OData, which seems unable to correctly decode these URLs in the batch request body.

Reproduce steps

  • Create a batch request using Postman
  • Include a request in the batch that contains a URL with an encoded URL (e.g., ../products(%27someid%27)).
  • Send the batch request to an ASP.NET Core 7 OData service.
  • The server responds with an Internal Server Error.

Request/Response
Request

--batch_c3f9057d-2492-4a77-b2a6-099d7c7adfe9
Content-Type: multipart/mixed; boundary=changeset_ae1277da-d1d0-473e-a0ae-b982bdaeb1fc

--changeset_ae1277da-d1d0-473e-a0ae-b982bdaeb1fc
Content-Type: application/http
Content-Transfer-Encoding: binary
Content-ID: 1

GET https://localhost:44377/odata/Products(%27someid%27) HTTP/1.1
If-Match: *


--changeset_ae1277da-d1d0-473e-a0ae-b982bdaeb1fc--
--batch_c3f9057d-2492-4a77-b2a6-099d7c7adfe9--

Response

--batchresponse_9cb15c52-d513-4f22-bfda-66c7ca50a75b
Content-Type: application/http
Content-Transfer-Encoding: binary

HTTP/1.1 500 Internal Server Error


--batchresponse_9cb15c52-d513-4f22-bfda-66c7ca50a75b--

Expected behavior

  • I expected the server to correctly process the batch request. In other words, the URL encoding should not cause any problems, as the server should automatically decode these URLs.

Additional context
It seems the URL encoding issue only arises when special characters are present in the URLs within the batch request body. Single requests work as expected, and batch requests without special characters in the URLs also work as expected.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.