Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] boundserror displaying HTTP response #260

Closed
ssfrr opened this issue Mar 20, 2019 · 2 comments
Closed

[BUG] boundserror displaying HTTP response #260

ssfrr opened this issue Mar 20, 2019 · 2 comments

Comments

@ssfrr
Copy link

ssfrr commented Mar 20, 2019

Details

  • Atom version: 1.34.0
  • Julia version: 1.1.0
  • OS: Arch Linux
  • Package versions:
    • Atom.jl:0.7.14
    • julia-client: 0.7.14
    • ink: 0.9.15

Steps to reproduce

using HTTP
HTTP.get("http://httpbin.org/image/png")

This displays the error:

BoundsError: attempt to access 256-element Array{Array{UInt8,1},1} at index [0]
getindex at array.jl:729 [inlined]
getindex at multidimensional.jl:458 [inlined]
write(::JSON.Writer.StringContext{JSON.Writer.CompactContext{Base.GenericIOBuffer{Array{UInt8,1}}}}, ::UInt8) at Writer.jl:123
unsafe_write at io.jl:197 [inlined]
macro expansion at gcutils.jl:87 [inlined]
write(::JSON.Writer.StringContext{JSON.Writer.CompactContext{Base.GenericIOBuffer{Array{UInt8,1}}}}, ::String) at io.jl:165
print at io.jl:167 [inlined]
show_string(::JSON.Writer.CompactContext{Base.GenericIOBuffer{Array{UInt8,1}}}, ::String) at Writer.jl:198
show_json at Writer.jl:251 [inlined]
show_element(::JSON.Writer.CompactContext{Base.GenericIOBuffer{Array{UInt8,1}}}, ::JSON.Serializations.StandardSerialization, ::String) at Writer.jl:218
show_json(::JSON.Writer.CompactContext{Base.GenericIOBuffer{Array{UInt8,1}}}, ::JSON.Serializations.StandardSerialization, ::Array{String,1}) at Writer.jl:293
show_pair(::JSON.Writer.CompactContext{Base.GenericIOBuffer{Array{UInt8,1}}}, ::JSON.Serializations.StandardSerialization, ::Symbol, ::Array{String,1}) at Writer.jl:241
show_pair(::JSON.Writer.CompactContext{Base.GenericIOBuffer{Array{UInt8,1}}}, ::JSON.Serializations.StandardSerialization, ::Pair{Any,Any}) at Writer.jl:243
show_json(::JSON.Writer.CompactContext{Base.GenericIOBuffer{Array{UInt8,1}}}, ::JSON.Serializations.StandardSerialization, ::Dict{Any,Any}) at Writer.jl:271
show_pair(::JSON.Writer.CompactContext{Base.GenericIOBuffer{Array{UInt8,1}}}, ::JSON.Serializations.StandardSerialization, ::Symbol, ::Dict{Any,Any}) at Writer.jl:241
show_pair(::JSON.Writer.CompactContext{Base.GenericIOBuffer{Array{UInt8,1}}}, ::JSON.Serializations.StandardSerialization, ::Pair{Any,Any}) at Writer.jl:243
show_json(::JSON.Writer.CompactContext{Base.GenericIOBuffer{Array{UInt8,1}}}, ::JSON.Serializations.StandardSerialization, ::Dict{Any,Any}) at Writer.jl:271
show_element(::JSON.Writer.CompactContext{Base.GenericIOBuffer{Array{UInt8,1}}}, ::JSON.Serializations.StandardSerialization, ::Dict{Any,Any}) at Writer.jl:218
show_json(::JSON.Writer.CompactContext{Base.GenericIOBuffer{Array{UInt8,1}}}, ::JSON.Serializations.StandardSerialization, ::Array{Any,1}) at Writer.jl:293
#show_json#3 at Writer.jl:325 [inlined]
show_json at Writer.jl:324 [inlined]
print(::Base.GenericIOBuffer{Array{UInt8,1}}, ::Array{Any,1}) at Writer.jl:349
#sprint#340(::Nothing, ::Int64, ::Function, ::Function, ::Array{Any,1}) at io.jl:101
sprint at io.jl:97 [inlined]
json at Writer.jl:354 [inlined]
msg(::String, ::Int64, ::Vararg{Any,N} where N) at comm.jl:125
handlemsg(::Dict{String,Any}, ::Dict{String,Any}) at comm.jl:165
(::getfield(Atom, Symbol("##19#21")){Array{Any,1}})() at task.jl:259
@ssfrr ssfrr added the bug label Mar 20, 2019
@pfitzseb
Copy link
Member

pfitzseb commented Apr 13, 2019

This is an upstream issue:

julia> using JSON, HTTP

julia> res = HTTP.get("http://httpbin.org/image/png");

julia> sres = sprint(show, res);

julia> JSON.json(sres)
ERROR: BoundsError: attempt to access 256-element Array{Array{UInt8,1},1} at index [0]

The problem is that JSON can't handle invalid UTF8 in strings, which is somewhat unfortunate.

@pfitzseb
Copy link
Member

Fixed by JunoLab/Atom.jl@6806431. That doesn't cover all cases, but is probably good enough for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants