Skip to content

Fix: stop relying on undocumented HTTP::Headers#to_json in debug log#188

Open
afinetooth wants to merge 1 commit into
masterfrom
fix-http-headers-debug-log
Open

Fix: stop relying on undocumented HTTP::Headers#to_json in debug log#188
afinetooth wants to merge 1 commit into
masterfrom
fix-http-headers-debug-log

Conversation

@afinetooth
Copy link
Copy Markdown
Member

Summary

One-line fix at src/coverage_reporter/api/jobs.cr:51, plus a regression spec.

The debug-log line was calling headers.to_pretty_json on an HTTP::Headers value, which silently relied on an undocumented Crystal stdlib overload (HTTP::Headers#to_json(JSON::Builder)). That overload vanished in Crystal 1.20.0 — the root cause of homebrew-coveralls#71 — and was only restored in 1.20.1 as an explicit forwarder the Crystal team has indicated was never intentional.

This change converts HTTP::Headers to a plain Hash before serializing, so we go through documented JSON paths only. Survives any future Crystal stdlib churn around HTTP::Headers serialization.

- Log.debug "---\n⛑ Debug Headers:\n#{headers.to_pretty_json}"
+ Log.debug "---\n⛑ Debug Headers:\n#{headers.to_a.to_h.to_pretty_json}"

The data payload itself was never affected — it's already a plain Hash made of @config.to_h, @source_files.map(&.to_h), and @git_info. Only the debug log line touched a raw HTTP::Headers for JSON.

Test plan

  • crystal spec spec/coverage_reporter/api/jobs_spec.cr — 6 examples, 0 failures (the new regression spec passes)
  • CI passes make test and make build

After merge

  • Cut 0.6.18 via make new_version (see README.md); GitHub Actions will publish bottles.
  • Reply on homebrew-coveralls#71 confirming the durable fix shipped, with the unblock recipe (brew update && brew upgrade crystal && brew reinstall coveralls).

Closes #187
Refs coverallsapp/homebrew-coveralls#71
Refs crystal-lang/crystal#16886

🤖 Generated with Claude Code

The debug log line at jobs.cr:51 invoked `headers.to_pretty_json` on an
HTTP::Headers value, which depends on an undocumented Crystal stdlib
overload `HTTP::Headers#to_json(JSON::Builder)`. That overload vanished
in Crystal 1.20.0, breaking the source build for Homebrew users without
matching bottles, and was only restored in 1.20.1 as an explicit forwarder
the Crystal team has signaled is unintentional.

Convert HTTP::Headers to a plain Hash before serializing so we go through
documented JSON paths only. Survives any future Crystal stdlib churn
around HTTP::Headers serialization.

Adds a regression spec exercising send_request under Log::Level::Debug.

Closes #187
Refs coverallsapp/homebrew-coveralls#71
Refs crystal-lang/crystal#16886

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@codacy-production
Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@coveralls-official
Copy link
Copy Markdown

Coverage Report for CI Build 25444807362

Coverage increased (+0.1%) to 94.171%

Details

  • Coverage increased (+0.1%) from the base build.
  • Patch coverage: 1 of 1 lines across 1 file are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 995
Covered Lines: 937
Line Coverage: 94.17%
Coverage Strength: 2.14 hits per line

💛 - Coveralls

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stop relying on undocumented HTTP::Headers#to_json — root cause of macOS Homebrew build failures

1 participant