fix(probes): correct inverted target_lang_name_en guard message#1934
Open
anxkhn wants to merge 1 commit into
Open
fix(probes): correct inverted target_lang_name_en guard message#1934anxkhn wants to merge 1 commit into
anxkhn wants to merge 1 commit into
Conversation
`TranslationMixin.__init__` raises a `ValueError` when `target_lang_name_en` is `None`, but the message read "Probe cannot operate with target_lang_name_en being set". That states the opposite of the guarded condition: the probe requires `target_lang_name_en` to be set and the check fires precisely when it is not. Anyone extending the mixin who hits this error was told to unset the value, which guarantees the failure persists. Reword the message to "cannot operate without target_lang_name_en being set" so the diagnostic matches the code's actual requirement. This is a message-only change with no behavioural effect. Add a regression test that instantiates a `TranslationMixin` subclass without `target_lang_name_en` and asserts the raised message states the value is required (and no longer describes the inverse condition). Co-authored-by: Claude <noreply@anthropic.com> Signed-off-by: Anas Khan <83116240+anxkhn@users.noreply.github.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.
Tell us what this change does:
garak.probes.latentinjection.TranslationMixin.__init__raises aValueErrorwhen
target_lang_name_enisNone, i.e. the mixin requirestarget_lang_name_ento be set and the guard fires precisely when it is not.The message, however, read:
That states the opposite of the guarded condition. Anyone extending the mixin
(for example a new translation-based probe subclass that forgets to set
target_lang_name_en) who hits this error is told to unset the value, whichguarantees the failure persists.
This changes one word so the diagnostic matches the code's actual requirement:
It is a message-only change with no behavioural effect. There is exactly one
occurrence of this string in the codebase, so the fix is complete.
A regression test is added in the existing
tests/probes/test_probes_latentinjection.py: it instantiates aTranslationMixinsubclass withouttarget_lang_name_en, asserts the raisedmessage states the value is required (
without target_lang_name_en), andasserts it no longer describes the inverse condition
(
operate with target_lang_name_en). No target/model backend is needed.Not a duplicate
gh pr list --state opensearches onlatentinjection,target_lang_name_en,and
TranslationMixinreturn no PR that touchesgarak/probes/latentinjection.py,target_lang_name_en, orTranslationMixin.The only two open PRs that mention the
latentinjectionmodule (1776 AgentHarm,1627 0DIN JEF) do not modify this file or symbol (confirmed via
gh pr diff --name-only); they reference it incidentally. No existing issuecovers this message.
AI assistance
AI assistance (Claude) was used to help identify and fix this bug; this is
disclosed here and attributed in the commit via a
Co-authored-by:trailer, asgarak's contribution guide requests. Every changed line has been reviewed and is
understood and defended by the human submitter.
Verification
python -m pytest tests/probes/test_probes_latentinjection.py -q-> 20 passedpython -m pytest tests/probes/test_probes.py -q-> 1148 passed, 1 failed; the single failure isprobes.audio.AudioAchillesHeelneeding optional depssoundfile/librosa(not installed here), unrelated to this change and pre-existingpython -m black --check garak/probes/latentinjection.py tests/probes/test_probes_latentinjection.py-> cleanTranslationMixinsubclass with notarget_lang_name_ennow raises aValueErrorwhose message correctly says the value must be set(No generator config, target run, or special hardware/software is relevant: this
is a message-only correctness fix with a unit-level regression test.)