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

HttpRequest.url() logs spaces in path segments as literal plus signs

Đang mở Phù hợp với người mới
#886 2 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

@sylvesterkaczmarek đang làm issue này rồi.

Từ ngày 18/8/2026.

  • #887 của @sylvesterkaczmarek — đang mở
  • #997 của @dpiet-oai — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
78/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ệ
kotlin
Lĩnh vực
api

Hướng nghiên cứu

Bắt đầu từ entry point HttpRequest.url() và kiểm tra cách URLEncoder được sử dụng cho các segment đường dẫn so với các component truy vấn. So sánh output của nó với cách xử lý đường dẫn được HttpUrl.Builder sử dụng bởi transport thực tế và với URL được LoggingHttpClient in ra. Được xem là hoàn tất khi khoảng trắng trong đường dẫn xuất hiện dưới dạng %20, khoảng trắng trong truy vấn vẫn giữ encoding + và các dấu cộng literal vẫn được encode chính xác.

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

Mô tả

Description

HttpRequest.url() uses URLEncoder for both query components and path segments:

append(URLEncoder.encode(segment, "UTF-8"))

URLEncoder applies form/query encoding semantics, where a space becomes +. That is valid for the query-string usage in the same method, but a + in a URL path is a literal plus character rather than a space escape.

As a result:

HttpRequest.builder()
    .method(HttpMethod.GET)
    .baseUrl("https://api.example.com")
    .addPathSegment("user name")
    .build()
    .url()

currently returns:

https://api.example.com/user+name

The actual OkHttp transport does not use this string to construct requests. It calls HttpUrl.Builder.addPathSegment("user name"), which sends the path as user%20name. LoggingHttpClient, however, prints request.url(), so the SDK log can show a different request target from the URL that was actually sent.

Expected behavior

HttpRequest.url() should percent-encode spaces in path segments as %20, while preserving the current + encoding for spaces in query parameters.

Impact

This is an observability/debugging correctness issue. Logs produced by LoggingHttpClient can misrepresent path parameters containing spaces, making reproduced requests target a different resource.

Suggested fix

Keep the existing form encoding for query components, but normalize the encoded path-segment result from + to %20. A literal + remains safe because URLEncoder already represents it as %2B.

Ngôn ngữ chính
Kotlin
Star
1.5k
Fork
268
Merge trung bình
14 giờ 12 phút
Pull request đã merge (30 ngày)
180

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 openai/openai-java

Tất cả issue của openai/openai-java

Issue tương tự

Thêm issue về Kotlin

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.