Skip to content

Fix PsrpOperator constructor validation to use provision checks inste… - #70656

Open
bujjibabukatta wants to merge 3 commits into
apache:mainfrom
bujjibabukatta:fix/#70296
Open

Fix PsrpOperator constructor validation to use provision checks inste…#70656
bujjibabukatta wants to merge 3 commits into
apache:mainfrom
bujjibabukatta:fix/#70296

Conversation

@bujjibabukatta

Copy link
Copy Markdown
Contributor

Summary

Part of the burn-down tracked in #70296.

PsrpOperator.__init__ validated command/powershell/cmdlet/arguments/parameters
using truthiness checks instead of is not None checks. Per the guidance in #70296,
"was this provided" checks are allowed to stay in __init__, but must use is not None
polarity rather than truthiness — so this is a fix in place, not a move to execute().

What was wrong

  • command/powershell/cmdlet were collected into a set before being passed to
    exactly_one(). If two of them happened to render to the same string, the set would
    collapse them and validation would incorrectly pass.
  • if arguments and ..., if parameters and ..., if cmdlet: treated an explicitly
    provided empty list/dict/string as "not provided", silently skipping validation.

Fix

Replaced truthiness checks with is not None checks, and pass fields to exactly_one()
directly instead of via a set. __init__ is now limited to this provision check plus
plain self.field = field assignments.

Testing

Added three regression tests in test_psrp.py covering: two duplicate field values,
an empty arguments list, and an empty parameters dict — all now correctly raise
ValueError.

Related: #70296

Was generative AI tooling used to co-author this PR?

  • Yes - Claude

Generated-by: Claude following the guidelines

@shahar1

shahar1 commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Please note that it's a competitor PR of #70347 (you may keep this open, but I might end up merging the other - depending which provides the best match first)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this file modified?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants