From 823f1a595328072fd4d33eeaeafe7b92e7c22508 Mon Sep 17 00:00:00 2001 From: Anshul Singhvi Date: Fri, 11 Sep 2026 20:02:04 -0400 Subject: [PATCH 1/2] Support HTTP.jl 2 HTTP.jl 2.0 removes String(::Message), rejects unknown request keywords, and wraps server request bodies in HTTP.BytesBody. Bump julia compat to 1.10, the floor HTTP.jl 2.0 requires. Co-Authored-By: Claude Opus 5 --- Project.toml | 4 ++-- src/codecovio.jl | 8 +++----- src/coveralls.jl | 2 +- test/runtests.jl | 2 +- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/Project.toml b/Project.toml index 3bba4ef..017b93f 100644 --- a/Project.toml +++ b/Project.toml @@ -20,12 +20,12 @@ ArgParse = "1" Artifacts = "1" CoverageTools = "1" Downloads = "1.6.0" -HTTP = "0.8, 0.9, 1" +HTTP = "2" JSON = "1" MbedTLS = "0.6, 0.7, 1" SHA = "0.7.0, 1" Scratch = "1" -julia = "1" +julia = "1.10" [extras] Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" diff --git a/src/codecovio.jl b/src/codecovio.jl index 6aa877a..ddb0cd1 100644 --- a/src/codecovio.jl +++ b/src/codecovio.jl @@ -297,7 +297,7 @@ function submit_generic(fcs::Vector{FileCoverage}, kwargs::Dict) # Tell Codecov we have an upload for them response = HTTP.post(uri_str; headers=Dict("Accept" => "text/plain")) # Get the temporary URL to use for uploading to S3 - repr = String(response) + repr = string(response) s3url = get(split(String(response.body), '\n'), 2, "") repr = chomp(replace(repr, s3url => "")) @debug "Result of submission:" * repr @@ -308,10 +308,8 @@ end function upload_to_s3(; s3url, fcs) startswith(s3url, "https://") || error("Invalid codecov response: $s3url") # Upload to S3 - request = HTTP.put(s3url; body=JSON.json(to_json(fcs)), - header=Dict("Content-Type" => "application/json", - "x-amz-storage-class" => "REDUCED_REDUNDANCY")) - @debug "Result of submission:" * mask_token(String(request)) + request = HTTP.put(s3url; body=JSON.json(to_json(fcs))) + @debug "Result of submission:" * mask_token(string(request)) end function construct_uri_string(kwargs::Dict) diff --git a/src/coveralls.jl b/src/coveralls.jl index c2b8885..07104b9 100644 --- a/src/coveralls.jl +++ b/src/coveralls.jl @@ -256,7 +256,7 @@ function post_request(data) coveralls_url = get(ENV, "COVERALLS_URL", "https://coveralls.io/api/v1/jobs") headers = [] req = HTTP.post(coveralls_url, headers, HTTP.Form(makebody(data))) - @debug "Result of submission:\n" * String(req) + @debug "Result of submission:\n" * string(req) nothing end diff --git a/test/runtests.jl b/test/runtests.jl index 24e770d..a6a5af2 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1178,7 +1178,7 @@ withenv( @test request.target == "/webhook?repo_token=token%20with%20%26%20symbols" @test HTTP.header(request, "Content-Type") == "application/json" - @test JSON.parse(request.body) == Dict( + @test JSON.parse(String(request.body)) == Dict( "payload" => Dict("build_num" => "123", "status" => "done")) secret = "secret token&value" From 15f16a05adfa5694865bd085cc584d70a91dd92e Mon Sep 17 00:00:00 2001 From: Anshul Singhvi Date: Fri, 11 Sep 2026 20:08:35 -0400 Subject: [PATCH 2/2] Send Content-Type on the Codecov v4 upload The PUT has gone out header-less since the v4 migration: the keyword was spelled `header`, which HTTP.jl never recognized. Codecov's own uploaders send no x-amz-* headers to the GCS-backed upload URL, so restore only Content-Type and assert it against the echo server. Co-Authored-By: Claude Opus 5 --- src/codecovio.jl | 4 +++- test/runtests.jl | 10 ++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/codecovio.jl b/src/codecovio.jl index ddb0cd1..fdb3cb5 100644 --- a/src/codecovio.jl +++ b/src/codecovio.jl @@ -308,8 +308,10 @@ end function upload_to_s3(; s3url, fcs) startswith(s3url, "https://") || error("Invalid codecov response: $s3url") # Upload to S3 - request = HTTP.put(s3url; body=JSON.json(to_json(fcs))) + request = HTTP.put(s3url; body=JSON.json(to_json(fcs)), + headers=Dict("Content-Type" => "application/json")) @debug "Result of submission:" * mask_token(string(request)) + return request end function construct_uri_string(kwargs::Dict) diff --git a/test/runtests.jl b/test/runtests.jl index a6a5af2..c62f9cd 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -585,14 +585,20 @@ withenv( @test masked == "https://enterprise-codecov-1.com/upload/v4?token=&build=t_job_num" @testset "Run the `Coverage.Codecov.upload_to_s3` function against the \"black hole\" server" begin + echo_server = "https://httpbingo.julialang.org/put" black_hole_server = get( ENV, "JULIA_COVERAGE_BLACK_HOLE_SERVER_URL_PUT", - "https://httpbingo.julialang.org/put", + echo_server, ) s3url = black_hole_server fcs = Vector{CoverageTools.FileCoverage}(undef, 0) - Coverage.Codecov.upload_to_s3(; s3url=s3url, fcs=fcs) + response = Coverage.Codecov.upload_to_s3(; s3url=s3url, fcs=fcs) + if black_hole_server == echo_server + echoed = JSON.parse(String(response.body))["headers"] + @test echoed["Content-Type"] == ["application/json"] + @test !any(startswith(lowercase(k), "x-amz-") for k in keys(echoed)) + end end end