refactor: consolidate Encode removal, POD fixes, and JSON post#28
Closed
Koan-Bot wants to merge 6 commits into
Closed
refactor: consolidate Encode removal, POD fixes, and JSON post#28Koan-Bot wants to merge 6 commits into
Koan-Bot wants to merge 6 commits into
Conversation
Replace the private Encode::_utf8_on() with utf8::decode() and Encode::is_utf8() with utf8::is_utf8(). Both are core Perl functions available since 5.8 — no module import needed. utf8::decode() is superior to _utf8_on(): it validates the byte sequence as legal UTF-8 before setting the flag, whereas _utf8_on() blindly flips the flag even on invalid bytes. This removes Encode from runtime prerequisites entirely (dist.ini, cpanfile, Makefile.PL), making the dependency tree lighter. Supersedes #10. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The maint audit (PR #15) fixed colors.pl but missed this one. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Fix uppercase URL => url in POD examples (would crash at runtime) - Add missing 'use Slack::WebHook' in examples/start-end.pl - Document body/content aliases for the text parameter - Remove dead comment in post_ok - Add tests: post_info, content alias, auto_detect_utf8=0, notify_slack single-string Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Switch _http_post() from HTTP::Tiny::post_form() with a `payload` parameter to HTTP::Tiny::post() with a JSON body. Slack webhooks accept both formats, but the JSON approach is cleaner: - The Content-Type header in _build__http is no longer dead code (post_form always overrode it with application/x-www-form-urlencoded) - Removes the unnecessary form-encoding layer around the JSON payload - Aligns with Slack's recommended JSON content-type approach No functional change — both formats produce identical results on the Slack API side. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
post() sends content as-is to the socket, unlike post_form() which handles encoding internally. When json->utf8(0) produces a Unicode string with wide characters (e.g. UTF-8 text), HTTP::Tiny fails with a 599 Internal Exception. Add utf8::encode() to ensure the JSON payload is bytes before posting. Update test JSON decoding to use utf8(1) to match the new byte format. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This was referenced Apr 23, 2026
Collaborator
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Consolidates the 3-PR dependency chain (#18 → #19 → #20) into a single reviewable PR.
Why
PRs #18, #19, and #20 all touch
lib/Slack/WebHook.pmandt/hooks.t, creating a strict merge-order dependency. Reviewing them required merging sequentially with rebases between each step — a friction that kept them unreviewed for 29 days. One PR is easier to review than three interdependent ones.How
Cherry-picked all commits from #18, #19, #20 onto a fresh branch from master and resolved the inter-branch conflicts (test code from #19 referenced
Encode::is_utf8andpost_form/payloadwhich were changed by #18 and #20).Changes included:
Encode::_utf8_on/Encode::is_utf8with coreutf8::decode/utf8::is_utf8. Drop runtime Encode dep from cpanfile/dist.ini/Makefile.PL.URL =>→url =>in POD, documentbody/contentaliases, add tests for post_info, content alias, auto_detect_utf8=0, notify_slack single-arg.post_form()withpost()+{ content => $json }, addutf8::encode()for byte safety, addt/http-format.tintegration test.Testing
t/http-format.t) validates actual HTTP requests against a local serverutf8::is_utf8,contentkey, andutf8(1)decodeSupersedes: #18, #19, #20
🤖 Generated with Claude Code
Quality Report
Changes: 7 files changed, 341 insertions(+), 30 deletions(-)
Code scan: clean
Tests: failed (FAILED)
Branch hygiene: clean
Generated by Kōan post-mission quality pipeline