Skip to content

incorrect base64 format #64

Open
Open
@ultradian

Description

@ultradian

I was using GitHub.file() to download some of the url files from Metadata.jl and found some did not base64decode correctly. Example:

file("JuliaLang/METADATA.jl", "ACME/url")

produces

GitHub.Content (all fields are Nullable):
  typ: "file"
  name: "url"
  path: "ACME/url"
  encoding: "base64"
  content: "Z2l0Oi8vZ2l0aHViLmNvbS9IU1UtQU5UL0FDTUUuamwuZ2l0Cg==\n"
  sha: "b5b82f0d5f1f349298b604abd2f1f6e77ca1ae64"
...

but
file("JuliaLang/METADATA.jl", "AWS/url").content.value
gives
"Z2l0Oi8vZ2l0aHViLmNvbS9KdWxpYUNsb3VkL0FXUy5qbC5naXQK\n"
and

base64decode("Z2l0Oi8vZ2l0aHViLmNvbS9KdWxpYUNsb3VkL0FXUy5qbC5naXQK\n")

ArgumentError: incorrect base64 format, block must be at least 2 and at most 4 bytes

 in b64decode!(::Array{UInt8,1}, ::Array{UInt8,1}) at ./base64.jl:68
 in read(::Base64DecodePipe, ::Type{UInt8}) at ./base64.jl:192
 in readbytes!(::Base64DecodePipe, ::Array{UInt8,1}, ::Int64) at ./io.jl:345
 in read(::Base64DecodePipe, ::Int64) at ./io.jl:368
 in base64decode(::String) at ./base64.jl:203

Out of the 1000 files I downloaded, about a third gave this error. I'm not sure if this is an issue with how the Content gets parsed internally and need something deeper. For my own purposes, I just fixed the strings by adding a = before the \n.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions