MultipartBody incorrectly appends a new line to string values

Đang mở Phù hợp với người mới
#2,257 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ó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
74/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ệ
java
Lĩnh vực
backend

Hướng nghiên cứu

Trước tiên, hãy tìm MultipartBody và logic tuần tự hóa multipart của nó, sau đó kiểm tra cách các giá trị phần kiểu chuỗi và dấu phân cách boundary được ghi. Thêm hoặc cập nhật một kiểm thử tuần tự hóa tập trung cho giá trị chuỗi không có ký tự xuống dòng ở cuối; đầu ra cần đặt CRLF của boundary đúng vị trí mà không thêm dòng mới vào giá trị.

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

Mô tả

The following code:

import com.microsoft.kiota.MultipartBody;

MultipartBody body = new MultipartBody();
body.addOrReplacePart("fileCreatedAt",  "text/plain", "2026-11-15T22:54:31.014Z");

Produces the following output, which has an incorrect extra \r\n after the value and before the separator:

--db526cd4e4a945aaa9f079d8c9497dbf
Content-Type: text/plain
Content-Disposition: form-data; name="fileCreatedAt"

2026-11-15T22:54:31.014Z

--db526cd4e4a945aaa9f079d8c9497dbf--

The correct serialisation should have the value on the line directly preceding the separator. I ran into issue with the current implementation with services (correctly) adding the new line to the end of the value, which then failed to match their validation regex.

The correct serialisation is:

--db526cd4e4a945aaa9f079d8c9497dbf
Content-Type: text/plain
Content-Disposition: form-data; name="fileCreatedAt"

2026-11-15T22:54:31.014Z
--db526cd4e4a945aaa9f079d8c9497dbf--

As per: https://www.rfc-editor.org/info/rfc2046/#section-5.1.1

NOTE: The CRLF preceding the boundary delimiter line is conceptually
attached to the boundary so that it is possible to have a part that
does not end with a CRLF (line break). Body parts that must be
considered to end with line breaks, therefore, must have two CRLFs
preceding the boundary delimiter line, the first of which is part of
the preceding body part, and the second of which is part of the
encapsulation boundary.

Happy to send you a PR to fix this if that would be useful.

Ngôn ngữ chính
Java
Star
38
Fork
37
Merge trung bình
1 ngày 2 giờ
Pull request đã merge (30 ngày)
42

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 microsoft/kiota-java

Tất cả issue của microsoft/kiota-java

Issue tương tự

Thêm issue về Java

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.