Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Creating a token returns a lowercased Location header, and POST without Content-Type returns 404

Đang mở
#2,699 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
72/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
csharp
Lĩnh vực
api, backend

Hướng nghiên cứu

Start with the token Location generation in TokenHandler.cs and the optional-body POST mappings in TokenEndpoints.cs; then read the lowercase URL and fallback routing setup in Program.cs. Add endpoint tests for mixed-case token IDs in the Location header and POST requests without a body or Content-Type. Done means the returned URL preserves the token ID’s case and both optional-body endpoints create tokens successfully.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug

Two problems with the token create endpoints. The Location header returned after creating a token points to a lowercased token id, so following it returns 404. Separately, POST /api/v2/projects/{projectId}/tokens (and the organization variant) returns 404 instead of creating a token when the request has no body and no Content-Type header, even though the body is documented as optional.

Where

What happens

  1. POST /api/v2/projects/{id}/tokens with Content-Type: application/json returns 201 and a header like Location: .../api/v2/tokens/abcdefghij.... RouteOptions.LowercaseUrls = true lowercases the whole generated path, including the id value. Token lookups are case-sensitive, so GET on that URL returns 404.
  2. curl -X POST -H "Authorization: Bearer <user token>" .../api/v2/projects/{id}/tokens (no body, no Content-Type) returns 404. The Accepts(...) content-type matcher filters out the token endpoint when there is no Content-Type, so the request falls through to the {**slug:nonfile} fallback, which returns 404 for non-GET requests. With Content-Type: application/json and an empty body, the same request returns 201.

I confirmed both behaviors with a minimal ASP.NET Core 10 app that uses the same routing options, endpoint metadata, and fallback route.

Expected

  • Location points to the created token, preserving its case.
  • A POST with no body creates a token with default settings, whether or not Content-Type is sent, or else the endpoint returns a clear 415/400 instead of 404.

Suggested fix

  • Build the token Location without the lowercasing link generator, for example $"/api/v2/tokens/{model.Id}" or by setting LowercaseUrls only for paths. Other entities use lowercase ObjectIds, so they aren't affected.
  • Drop the Accepts content-type constraint on the two optional-body create endpoints, or treat a missing Content-Type as acceptable when the body is empty. Add endpoint tests for both cases.
Ngôn ngữ chính
C#
Star
2.5k
Fork
508
Merge trung bình
2 ngày 17 giờ
Pull request đã merge (30 ngày)
40

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của exceptionless/Exceptionless

Tất cả issue của exceptionless/Exceptionless

Issue tương tự

Thêm issue về C#

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.