fix(blocklist/whitelist): localize the export/import failure reasons (#456)#470
Merged
Conversation
…456) Both plugins render every success reason and most failure reasons through a lang template, but three technical failure returns in the JSONL export/import helpers were raw English literals - "open failed: <io error>" (export + import) and "json.encode failed: <error>" (export) - and the dispatcher's `reply( msg or tostring( err ) )` surfaced them verbatim regardless of cfg.language. (The issue also listed `add` as affected; re-derived from source, `add` was already localized - do_add_entry always returns a utf_format(msg_*) message - so only the three export/import strings were the real gap.) Fixed by adding two per-reason keys, msg_open_failed ("Could not open %s: %s", now also naming the path) and msg_encode_failed ("JSON encode failed: %s"), in en + de for both plugins, and routing the three raw returns through them - matching the plugins' existing per-reason localization convention. The per-row _sanitize_import_row reasons are deliberately left English: they route to hub_debug only (script log), never to the operator reply, which shows the already-localized added/skipped/errors summary. Also gave etc_blocklist the _do_export_jsonl / _do_import_jsonl test seams its twin etc_whitelist already exported (§1a.1 twin parity). Both plugins v0.02 -> v0.03. Provably fails pre-fix (§1a.7): etc_blocklist_test.lua (via the real dispatcher) and etc_whitelist_test.lua (via the seams), both already on each smoke.yml leg, gain cases that force an import open-failure and an export encode-failure and assert the reply renders the template ("Could not open" / "JSON encode failed") and no longer the raw strings - four checks per plugin, red on the unpatched code. Co-Authored-By: Claude Opus 4.8 (1M context) <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.
Closes #456.
+blocklist/+whitelist exportandimportprinted their failure reason in English regardless ofcfg.language. Both plugins localise every success reason and most failure reasons through a lang template, but three technical failure returns in the JSONL helpers were raw English literals -"open failed: <io error>"(export + import) and"json.encode failed: <error>"(export) - and the dispatcher'sreply( msg or tostring( err ) )surfaced them verbatim.Correction to the issue (§1a.4)
The issue's table also listed
addas affected. Re-derived from source,addwas already localised -do_add_entryalways returns autf_format( msg_*, ... )message - so only the three export/import strings were the real gap.Fix
msg_open_failed("Could not open %s: %s", now also naming the path) andmsg_encode_failed("JSON encode failed: %s"), matching the plugins' existing per-reason localisation convention. The three raw returns route through them._sanitize_import_rowreasons stay English by design: they go tohub_debug(script log) only, never to the operator reply, which shows the already-localised added/skipped/errors summary.etc_blocklistgains the_do_export_jsonl/_do_import_jsonltest seams its twinetc_whitelistalready exported (§1a.1 twin parity).Tests (§1a.7)
etc_blocklist_test.lua(via the real command dispatcher) andetc_whitelist_test.lua(via the seams) - both already registered on each smoke.yml leg - gain cases that force an import open-failure and an export encode-failure and assert the reply renders the template ("Could not open"/"JSON encode failed") and no longer the raw"open failed:"/"json.encode failed:". Four checks per plugin, red on the unpatched code (verified: 4 failures/plugin on HEAD, green patched).plugin_lang_teststays green (4300/4300) with the new keys wired in both languages.Review (§1a.6)
Independent reviewer + maintainer spot-check: no blockers, no concerns. Verified
%s/arg-count parity at all 6 sites (en/de templates match), the de ASCII transliteration, twin parity, that nothing else changed, that the_sanitize_import_rowreasons are genuinely operator-invisible, and the tests discriminate (both assertion directions red pre-fix). Lang files stay LF / no-BOM. One CHANGELOG precision NIT folded in (cite #458 for the earlier template removal).3.2.x only, not backported.
🤖 Generated with Claude Code