Skip to content

Create or Update file fails when content length > 57  #638

@asthinasthi

Description

@asthinasthi

Describe the bug
When we invoke commit() with content length > 57

The API fails with 422, invalid Base 64 encoding

If we have a content 1234567890123456789012345678901234567890123456789012345678 of length 58.

Base64 encoding is

MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3OA==

MIME encoding looks like

MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3
OA==

MIME encoding breaks the string into chunks of 76. This is rejected by Github API

This could be due to the recent change ?
https://github.com/github-api/github-api/blob/d1507f26668950508e0bf242c34cdb599003991a/src/main/java/org/kohsuke/github/GHContentBuilder.java#L71
To Reproduce
Steps to reproduce the behavior:
Invoke the method with content of length >57

Expected behavior
The commit must be successful

Desktop (please complete the following information):
1.102-SNAPSHOT

Additional context
I was able to fix this issue locally by using Base64.getEncoder().encodeToString()

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions