Repository navigation
FIX: Only advertise converter_target when the converter declares it - #3382
Open
Chen Yufeiyang (feiiiiii5) wants to merge 2 commits into
Open
Chen Yufeiyang (feiiiiii5) wants to merge 2 commits into
Chen Yufeiyang (feiiiiii5) wants to merge 2 commits into
Conversation
…icrosoft#3341) Converter.__init__ accepts converter_target only so subclasses can forward a target to it for validation. Eight converters inherit that parameter without declaring it, so the derived contract (and the registry UI, including the LLM badge projected from it) claimed a target input they do not have, and a cleared target selection was resolved as a registry name and failed with an empty-name not-found error. - derive_parameters gains seam_base_type: a non-required reference the base declares is excluded from a subclass's contract unless the subclass redeclares it; required base references and class-declared optional ones are kept. ConverterRegistry opts in; other registries are unchanged. - resolve_constructor_args treats an empty-string reference value as a cleared selection: the constructor default (or an apply_defaults-registered default) applies instead of an empty-name lookup.
This branch has not been deployed
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.
Description
Fixes #3341.
Clearing (or leaving at the placeholder) the
converter_targetselect for a converter likeArabiziConverterfailed withArabiziConverter.converter_target: '' not found in DefaultInstanceRegistry …— an error that neither matches the converter's actual contract nor tells the user what to do.Two root causes:
ConverterIdentifierpromotes every constructor parameter namedconverter_targetto a TARGET reference. Eight converters only inheritConverter.__init__'sconverter_target=None— a seam the base validates and discards so subclasses can forward a target tosuper().__init__()— yet the derived contract advertised a target for them, including the LLM badge projected from it:ArabiziConverter,ArabicPresentationFormConverter,BrailleConverter,CharacterSpaceConverter,FlipConverter,JsonStringConverter,UrlConverter,ZeroWidthConverter.converter_target: "", andresolve_constructor_argslooked""up as a registry name.The fix, along the lines Richard Lundeen (@richlundeen) described in #3038 ("a separate check of the converter's constructor requirements and registry metadata, plus a clearer validation error"):
derive_parametersgainsseam_base_type: a non-required reference declared by that base is a construction seam, excluded from a subclass's contract unless the subclass redeclares it. Required base references and class-declared optional ones stay.Registry._seam_base_type()defaults toNone, and onlyConverterRegistryopts in — deliberately per-registry, since for example the Scorer base also declares an optionalchat_targetthat is not a seam.resolve_constructor_argstreats an empty-string reference value as an unsupplied selection: the constructor default applies (includingapply_defaults-registered defaults, the FEAT: Default converter targets to the adversarial target #3038 feature) instead of an empty-name lookup.Metadata and creation derive through the same path, so the advertised contract and the build contract cannot drift.
85d4f0c38f3b1a21ArabiziConvertermetadatais_llm_based=FalseArabiziConverter+converter_target=""'' not found in DefaultInstanceRegistryUnknown parameter 'converter_target' for 'ArabiziConverter'PuzzledConverter+converter_target=""'' not found …_converter_target is NoneTranslationConverter+converter_target=""'' not found …converter_target is required for TranslationConverter …Related: #3038 (merged) added default-target behavior for genuinely LLM-backed converters; this fixes the different seam path that made eight non-LLM converters advertise a target at all.
Tests and Documentation
15 new unit tests in
tests/unit/registry/cover the seam exclusion (optional base reference dropped; required and subclass-redeclared references kept), the metadata of the eight converters, the class-declared targets staying advertised, an invariant that no advertised target comes from the base seam, and the create paths above. Verified red at base where applicable: the seam tests fail withoutseam_base_type, and each cleared-target build fails on base with the registry-lookup error.tests/unit/registry+tests/unit/converter: identical 53 pre-existing environment failures on base and head; 3414 → 3429 passing.tests/unit/backend: identical outcomes base/head (2736 passing).ruff 0.17.0 check/formatclean. No documentation change applies; the dialog renders whatever the registry publishes, so the field and badge disappear structurally.Environment notes for the runs above
tests/unit/registry/test_attack_technique_registry.pydoes not collect locally (nopyritdistribution metadata) on base either; excluded from both runs.