MultipartBody incorrectly appends a new line to string values

Ouverte Adaptée aux débutants
#2,257 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
2/5
Temps estimé
1-3 heures
Accessibilité débutants
74/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
java
Domaine
backend

Piste de recherche

Commencez par repérer MultipartBody et sa logique de sérialisation multipart, puis examinez comment sont écrites les valeurs de parties de type chaîne et les séparateurs de boundary. Ajoutez ou mettez à jour un test de sérialisation ciblé pour une valeur de type chaîne sans saut de ligne final ; la sortie doit placer correctement le CRLF du boundary, sans ajouter de saut de ligne supplémentaire à la valeur.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

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.

Langage dominant
Java
Étoiles
38
Forks
37
Merge moyen
1 j 2 h
PR mergées (30 j)
42

Préparer son environnement

Ouvrir dans Codespaces

Lance le conteneur de développement du projet dans votre navigateur, avec votre propre compte GitHub.

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de microsoft/kiota-java

Toutes les issues de microsoft/kiota-java

Issues similaires

Plus d'issues Java

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.