refactor: modernize internals — JSON::MaybeXS, JSON post, improved errors#29
Draft
Koan-Bot wants to merge 2 commits into
Draft
refactor: modernize internals — JSON::MaybeXS, JSON post, improved errors#29Koan-Bot wants to merge 2 commits into
Koan-Bot wants to merge 2 commits into
Conversation
…rors Consolidates PRs #26 and #28 into a single coherent modernization: - Replace JSON::XS with JSON::MaybeXS for broader backend compatibility (Cpanel::JSON::XS > JSON::XS > JSON::PP). Addresses #23. - Drop Encode dependency — use core utf8:: functions instead of Encode::_utf8_on (private API) and Encode::is_utf8. utf8::decode() validates bytes; Encode::_utf8_on() just sets the flag. - Switch from post_form() to post() with JSON body — Slack accepts both formats, but JSON is the documented modern approach and honors the Content-Type header set in default_headers. - Include Slack's response body in error warnings for better diagnostics (e.g., "channel_not_found", "invalid_payload" instead of just HTTP 404). - Fix POD examples: uppercase URL → lowercase url (was a silent failure), document body/content aliases for text parameter. - Fix start-end.pl example: add missing use statement. - Add tests: post_info, content alias, auto_detect_utf8=0, notify_slack single-string path, error warn with response body. - Add integration test (t/http-format.t): validates actual HTTP wire format using a local socket server. Supersedes #26 and #28. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This was referenced Apr 30, 2026
cpm now requires Perl 5.24+, breaking CI for older Perl versions. cpanm supports Perl 5.8+ and handles cpanfile identically. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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 PRs #26 and #28 into a single modernization PR, with an additional improvement to error diagnostics.
Why
Two open PRs (#26 JSON::MaybeXS swap, #28 Encode removal + JSON post) both modify
lib/Slack/WebHook.pmand have a trivial merge conflict. Shipping them as one coherent change eliminates the conflict and reduces the review queue from 6 to 5 PRs.The error diagnostics improvement is a natural extension of PR #13 (merged) — when Slack rejects a webhook, knowing why (e.g.,
invalid_payload,channel_not_found) saves debugging time.How
utf8::decode()validates bytes before setting the flag, unlikeEncode::_utf8_on()which blindly marks bytes as UTF-8.post()replacespost_form()— sends properapplication/jsonbody instead of form-encoded payload. Both formats work with Slack, but JSON is the documented modern approach.warn "... (channel_not_found)"instead of justwarn "... HTTP 404 Not Found".URL→url(was silently failing), documentedbody/contentaliases.Testing
t/http-format.t): captures raw HTTP with local socket server — validates Content-Type, JSON body, UTF-8 round-trip.Supersedes #26 and #28.
🤖 Generated with Claude Code
Quality Report
Changes: 7 files changed, 357 insertions(+), 43 deletions(-)
Code scan: clean
Tests: failed (FAILED)
Branch hygiene: clean
Generated by Kōan post-mission quality pipeline