HTTP returns an error in Julia 1.11.1

I have just updated to Julia 1.11.1 and HTTP is now returning an error, where it worked before the update. Any thoughts would be appreciated.

The call is very simple:

resp = HTTP.request("GET", "http://httpbin.org/ip")

This code returns the following:

	"name": "MethodError",
	"message": "MethodError: Cannot `convert` an object of type 
  SubArray{UInt8,1,Memory{UInt8},Tuple{UnitRange{Int64}},true} to an object of type 
  SubArray{UInt8,1,Vector{UInt8},Tuple{UnitRange{Int64}},true}
The function `convert` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  SubArray{T, N, P, I, L}(::Any, !Matched::Any, !Matched::Any, !Matched::Any) where {T, N, P, I, L}
   @ Base subarray.jl:19
  convert(::Type{T}, !Matched::T) where T
   @ Base Base.jl:126
  convert(::Type{T}, !Matched::LinearAlgebra.Factorization) where T<:AbstractArray
   @ LinearAlgebra /Applications/Julia-1.11.app/Contents/Resources/julia/share/julia/stdlib/v1.11/LinearAlgebra/src/factorization.jl:104
  ...
",
	"stack": "MethodError: Cannot `convert` an object of type 
  SubArray{UInt8,1,Memory{UInt8},Tuple{UnitRange{Int64}},true} to an object of type 
  SubArray{UInt8,1,Vector{UInt8},Tuple{UnitRange{Int64}},true}
The function `convert` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  SubArray{T, N, P, I, L}(::Any, !Matched::Any, !Matched::Any, !Matched::Any) where {T, N, P, I, L}
   @ Base subarray.jl:19
  convert(::Type{T}, !Matched::T) where T
   @ Base Base.jl:126
  convert(::Type{T}, !Matched::LinearAlgebra.Factorization) where T<:AbstractArray
   @ LinearAlgebra /Applications/Julia-1.11.app/Contents/Resources/julia/share/julia/stdlib/v1.11/LinearAlgebra/src/factorization.jl:104
  ...


Stacktrace:
  [1] readuntil(buf::IOBuffer, find_delimiter::typeof(HTTP.Parsers.find_end_of_header))
    @ HTTP.IOExtras ~/.julia/packages/HTTP/aTjcj/src/IOExtras.jl:139
  [2] readuntil(t::HTTP.ConnectionPool.Transaction{MbedTLS.SSLContext}, f::Function, sizehint::Int64)
    @ HTTP.ConnectionPool ~/.julia/packages/HTTP/aTjcj/src/ConnectionPool.jl:296
  [3] readuntil(t::HTTP.ConnectionPool.Transaction{MbedTLS.SSLContext}, f::Function)
    @ HTTP.ConnectionPool ~/.julia/packages/HTTP/aTjcj/src/ConnectionPool.jl:292
  [4] readheaders(io::HTTP.ConnectionPool.Transaction{MbedTLS.SSLContext}, message::HTTP.Messages.Response)
    @ HTTP.Messages ~/.julia/packages/HTTP/aTjcj/src/Messages.jl:537
  [5] startread(http::HTTP.Streams.Stream{HTTP.Messages.Response, HTTP.ConnectionPool.Transaction{MbedTLS.SSLContext}})
    @ HTTP.Streams ~/.julia/packages/HTTP/aTjcj/src/Streams.jl:170
  [6] macro expansion
    @ ~/.julia/packages/HTTP/aTjcj/src/StreamRequest.jl:67 [inlined]
  [7] macro expansion
    @ ./task.jl:498 [inlined]
  [8] request(::Type{StreamLayer{Union{}}}, io::HTTP.ConnectionPool.Transaction{MbedTLS.SSLContext}, req::HTTP.Messages.Request, body::Vector{UInt8}; reached_redirect_limit::Bool, response_stream::Nothing, iofunction::Nothing, verbose::Int64, kw::@Kwargs{})
    @ HTTP.StreamRequest ~/.julia/packages/HTTP/aTjcj/src/StreamRequest.jl:57
  [9] request(::Type{ConnectionPoolLayer{StreamLayer{Union{}}}}, url::URIs.URI, req::HTTP.Messages.Request, body::Vector{UInt8}; proxy::Nothing, socket_type::Type, reuse_limit::Int64, kw::@Kwargs{iofunction::Nothing, reached_redirect_limit::Bool})
    @ HTTP.ConnectionRequest ~/.julia/packages/HTTP/aTjcj/src/ConnectionRequest.jl:108
 [10] request(::Type{ExceptionLayer{ConnectionPoolLayer{StreamLayer{Union{}}}}}, ::URIs.URI, ::Vararg{Any}; kw::@Kwargs{iofunction::Nothing, reached_redirect_limit::Bool})
    @ HTTP.ExceptionRequest ~/.julia/packages/HTTP/aTjcj/src/ExceptionRequest.jl:19
 [11] (::Base.var\"#106#108\"{Base.var\"#106#107#109\"{ExponentialBackOff, HTTP.RetryRequest.var\"#2#3\"{Bool, HTTP.Messages.Request}, typeof(HTTP.request)}})(::Type, ::Vararg{Any}; kwargs::@Kwargs{iofunction::Nothing, reached_redirect_limit::Bool})
    @ Base ./error.jl:300
 [12] request(::Type{RetryLayer{ExceptionLayer{ConnectionPoolLayer{StreamLayer{Union{}}}}}}, url::URIs.URI, req::HTTP.Messages.Request, body::Vector{UInt8}; retries::Int64, retry_non_idempotent::Bool, kw::@Kwargs{iofunction::Nothing, reached_redirect_limit::Bool})
    @ HTTP.RetryRequest ~/.julia/packages/HTTP/aTjcj/src/RetryRequest.jl:44
 [13] request(::Type{MessageLayer{RetryLayer{ExceptionLayer{ConnectionPoolLayer{StreamLayer{Union{}}}}}}}, method::String, url::URIs.URI, headers::Vector{Pair{SubString{String}, SubString{String}}}, body::Vector{UInt8}; http_version::VersionNumber, target::String, parent::Nothing, iofunction::Nothing, kw::@Kwargs{reached_redirect_limit::Bool})
    @ HTTP.MessageRequest ~/.julia/packages/HTTP/aTjcj/src/MessageRequest.jl:66
 [14] request(::Type{BasicAuthLayer{MessageLayer{RetryLayer{ExceptionLayer{ConnectionPoolLayer{StreamLayer{Union{}}}}}}}}, method::String, url::URIs.URI, headers::Vector{Pair{SubString{String}, SubString{String}}}, body::Vector{UInt8}; kw::@Kwargs{reached_redirect_limit::Bool})
    @ HTTP.BasicAuthRequest ~/.julia/packages/HTTP/aTjcj/src/BasicAuthRequest.jl:28
 [15] request(::Type{RedirectLayer{BasicAuthLayer{MessageLayer{RetryLayer{ExceptionLayer{ConnectionPoolLayer{StreamLayer{Union{}}}}}}}}}, method::String, url::URIs.URI, headers::Vector{Pair{SubString{String}, SubString{String}}}, body::Vector{UInt8}; redirect_limit::Int64, forwardheaders::Bool, kw::@Kwargs{})
    @ HTTP.RedirectRequest ~/.julia/packages/HTTP/aTjcj/src/RedirectRequest.jl:28
 [16] request(::Type{RedirectLayer{BasicAuthLayer{MessageLayer{RetryLayer{ExceptionLayer{ConnectionPoolLayer{StreamLayer{Union{}}}}}}}}}, method::String, url::URIs.URI, headers::Vector{Pair{SubString{String}, SubString{String}}}, body::Vector{UInt8})
    @ HTTP.RedirectRequest ~/.julia/packages/HTTP/aTjcj/src/RedirectRequest.jl:18
 [17] request(::Type{TopLayer{RedirectLayer{BasicAuthLayer{MessageLayer{RetryLayer{ExceptionLayer{ConnectionPoolLayer{StreamLayer{Union{}}}}}}}}}}, ::String, ::Vararg{Any}; kwargs::@Kwargs{})
    @ HTTP.TopRequest ~/.julia/packages/HTTP/aTjcj/src/TopRequest.jl:15
 [18] request(::Type{TopLayer{RedirectLayer{BasicAuthLayer{MessageLayer{RetryLayer{ExceptionLayer{ConnectionPoolLayer{StreamLayer{Union{}}}}}}}}}}, ::String, ::URIs.URI, ::Vector{Pair{SubString{String}, SubString{String}}}, ::Vector{UInt8})
    @ HTTP.TopRequest ~/.julia/packages/HTTP/aTjcj/src/TopRequest.jl:15
 [19] request(method::String, url::String, h::Vector{Pair{SubString{String}, SubString{String}}}, b::Vector{UInt8}; headers::Vector{Pair{SubString{String}, SubString{String}}}, body::Vector{UInt8}, query::Nothing, kw::@Kwargs{})
    @ HTTP ~/.julia/packages/HTTP/aTjcj/src/HTTP.jl:330
 [20] request (repeats 2 times)
    @ ~/.julia/packages/HTTP/aTjcj/src/HTTP.jl:328 [inlined]
 [21] get(a::String)
    @ HTTP ~/.julia/packages/HTTP/aTjcj/src/HTTP.jl:407
 [22] top-level scope
    @ ~/Programming/Julia/energy/jl_notebook_cell_df34fa98e69747e1a8f8a730347b8e2f_W2sZmlsZQ==.jl:3"
}

Seems to work fine for me:

julia> using HTTP

julia> resp = HTTP.request("GET", "http://httpbin.org/ip")
HTTP.Messages.Response:
"""
HTTP/1.1 200 OK
Date: Wed, 06 Nov 2024 02:15:01 GMT
Content-Type: application/json
Content-Length: 31
Connection: keep-alive
Server: gunicorn/19.9.0
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true

{
  "origin": "90.219.96.84"
}
"""

julia> versioninfo()
Julia Version 1.11.1
Commit 8f5b7ca12ad (2024-10-16 10:53 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: macOS (arm64-apple-darwin22.4.0)
  CPU: 8 × Apple M1
  WORD_SIZE: 64
  LLVM: libLLVM-16.0.6 (ORCJIT, apple-m1)
Threads: 1 default, 0 interactive, 1 GC (on 4 virtual cores)

(jl_wdo6uY) pkg> st
Status `/private/var/folders/v2/hmy3kzgj4tb3xsy8qkltxd0r0000gn/T/jl_wdo6uY/Project.toml`
  [cd3eb016] HTTP v1.10.9

As it turns out, I had an old version of the HTTP package installed. It could not be updated due to the presence of the Temporal package. I removed Temporal, updated HTTP. Now everything is working.

Hi, This is a very recent issue seeming to be related to the new Julia Version 1.11.

My previous code using HTTP worked fine, but now gives the same error as incurred above:

julia> show(err)
1-element ExceptionStack:
LoadError: MethodError: Cannot `convert` an object of type
  SubArray{UInt8,1,Memory{UInt8},Tuple{UnitRange{Int64}},true} to an object of type
  SubArray{UInt8,1,Vector{UInt8},Tuple{UnitRange{Int64}},true}
The function `convert` exists, but no method is defined for this combination of argument types.

It seems to be some incompatibility with the HTTP package and the new Julia version.

If anyone can help me please. I have updated my HTTP to v1.10.10 but even the following does not work for me.

resp = HTTP.get("http://httpbin.org/ip") #error is: Method Error: Cannot 'convert' and object of type

Yet if i run the url call in a browser it works fine. Appreciate your support!

julia> using HTTP

julia> HTTP.get("http://httpbin.org/ip")
HTTP.Messages.Response:
"""
HTTP/1.1 200 OK
Date: Sun, 17 Nov 2024 05:24:17 GMT
Content-Type: application/json
Content-Length: 30
Connection: keep-alive
Server: gunicorn/19.9.0
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true

"""

(jl_UvIZN2) pkg> st
Status `/tmp/jl_UvIZN2/Project.toml`
  [cd3eb016] HTTP v1.10.10

can you post the ]st output?

1 Like

Hi Jling, Appreciate the support.
I’ve managed to figure out a few things.
I have two computers: 1) Toshiba, 2) Dell.

Yesterday i loaded up JuliaInXL v1.2.0 (on the Dell) and had been experimenting with this. This morning I went back to my code that uses the HTTP (on the Dell) and this is when the trouble started.

This afternoon (after a lot of pondering) i went back to the Toshiba (which did not have the JuliaInXL installed) and all the code worked fine!

The following is my Toshiba ]status :
(@v1.11) pkg> st
Status C:\Users\A\.julia\environments\v1.11\Project.toml
[a93c6f00] DataFrames v1.7.0
[cd3eb016] HTTP v1.10.10
[682c06a0] JSON v0.21.4
[9e3dc215] TimeSeries v0.24.2
[fdbf4ff8] XLSX v0.10.4
[ade2ca70] Dates v1.11.0

which delivers the following successfully:

julia> resp = HTTP.get("http://httpbin.org/ip")
HTTP.Messages.Response:
"""
HTTP/1.1 200 OK
Date: Sun, 17 Nov 2024 11:33:07 GMT
Content-Type: application/json
Content-Length: 30
Connection: keep-alive
Server: gunicorn/19.9.0
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true

So then i started cleaning up the Dell packages. After cleaning out a lot of the packages, below is my Dell ]status :

(@v1.11) pkg> st
Status `C:\Users\A\.julia\environments\v1.11\Project.toml`
  [9600883c] JuliaInXL v1.2.0

(@v1.11) pkg> add HTTP
   Resolving package versions...
    Updating `C:\Users\P\.julia\environments\v1.11\Project.toml`
⌅ [cd3eb016] + HTTP v0.9.17
  No Changes to `C:\Users\P\.julia\environments\v1.11\Manifest.toml`

I then ran the same HTTP call and it gives the following error:

ERROR: MethodError: Cannot `convert` an object of type 
  SubArray{UInt8,1,Memory{UInt8},Tuple{UnitRange{Int64}},true} to an object of type 
  SubArray{UInt8,1,Vector{UInt8},Tuple{UnitRange{Int64}},true}
The function `convert` exists, but no method is defined for this combination of argument types.

So i think it’s version compatibility with JuliaInXL, however when i run:

] 
rm JuliaInXL then upgrade the HTTP to v1.10.10
like so,
(@v1.11) pkg> status
Status `C:\Users\P\.julia\environments\v1.11\Project.toml`
  [cd3eb016] HTTP v1.10.10

When i go back and run the HTTP code, it still won’t work on the Dell.

Any thoughts on how to restore functionality to the HTTP package? Appreciate your support!

1 Like

you just gotta remove that I guess

1 Like

Yes, i removed it, but there is still some conflict. Even despite the HTTPv1.10.10 now.

Maybe i have to delete a folder or files somewhere? Appreciate your insight.

Always a good idea to use a separate Project.toml file per project. E.g.:

mkdir myproject
cd myproject
julia --project="."

And then in Julia:

]
add HTTP
add ... # all the other packages you need

And if you add your additional packages one by one you would also see if one of the additional packages causes HTTP to be downgraded.

See also: Working with Julia projects | Julia programming notes

2 Likes

thanks Jling, ufechner7… appreciate the help. Should be good from here…

1 Like