Skip to content

Fix None injection for hoisted binary arguments#10369

Open
LeSingh1 wants to merge 1 commit into
aws:developfrom
LeSingh1:fix-binaryhoist-none-injection
Open

Fix None injection for hoisted binary arguments#10369
LeSingh1 wants to merge 1 commit into
aws:developfrom
LeSingh1:fix-binaryhoist-none-injection

Conversation

@LeSingh1
Copy link
Copy Markdown

@LeSingh1 LeSingh1 commented Jun 1, 2026

Summary

InjectingArgument.add_to_params in awscli/customizations/binaryhoist.py used pass instead of return in its None guard. When an optional hoisted binary argument is omitted, the method falls through and still injects the wrapped member with a None value.

The sibling class OriginalArgument.add_to_params (same file) correctly returns on None, which confirms the intended behavior.

Impact

This affects the hoisted binary blob arguments:

  • aws translate import-terminology (--data-file)
  • aws translate translate-document (--document-content)

When the optional argument is omitted, the serialized parameters get polluted, e.g. {'TerminologyData': {'File': None}} instead of staying empty.

Reproduction

from awscli.customizations.binaryhoist import InjectingArgument
arg = InjectingArgument('TerminologyData', 'File', name='data-file', cli_type_name='blob', required=False)
params = {}
arg.add_to_params(params, None)
# before: {'TerminologyData': {'File': None}}
# after:  {}

Fix

     def add_to_params(self, parameters, value):
         if value is None:
-            pass
+            return

Tests

Added tests/unit/customizations/test_binaryhoist.py with three cases (None, wrapping, merge-with-existing). The None case fails before the change and passes after. Verified locally:

$ python -m pytest tests/unit/customizations/test_binaryhoist.py -q
3 passed

Developed with AI assistance and verified locally as described above.

InjectingArgument.add_to_params used `pass` instead of `return` in the
None guard, so when an optional hoisted argument was omitted the code
still injected the wrapped member with a None value. The sibling
OriginalArgument.add_to_params returns on None, which is the intended
behavior. This affects `aws translate import-terminology` (--data-file)
and `aws translate translate-document` (--document-content): leaving the
optional arg off produced parameters like {'TerminologyData': {'File':
None}} instead of an empty mapping.

Added unit tests covering the None case, the wrapping case, and the
merge-with-existing case.
@LeSingh1 LeSingh1 requested a review from a team as a code owner June 1, 2026 05:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant