AAP-52517: Fix project.py: allow clearing credential with empty value - #16622
sussen-redhat wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe project module now converts falsey association values to ChangesProject credential clearing
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to The project module now treats an empty credential value as a request to clear the credential, with focused tests covering the behavior; no actionable merge-blocking risk remains after normal checks and review. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
bd9375b to
1585302
Compare
Signed-off-by: sussen-redhat <sussen@redhat.com>
1585302 to
dd0e23b
Compare
SUMMARY
This addresses the same root cause reported in #14843 (empty value not
clearing a credential field), but for the
projectmodule'scredentialand
signature_validation_credentialfields rather thanjob_template'swebhook_credential.Both fields were always passed through
resolve_name_to_id()when notNone, even when the value was an empty string (""). This caused themodule to try to look up a credential literally named
""and fail with"Request to /api/controller/v2/credentials/ returned N items, expected 1",
instead of treating an empty string as "clear this field" (which the UI
already supports).
This change treats a falsy-but-not-
Nonevalue (i.e."") as an explicitrequest to clear the field, setting it to
nullinstead of attempting nameresolution.
Note: this also changes behavior for
default_environment(the thirdfield in the same loop) — passing
default_environment: ""will nowalso clear that field rather than attempting to resolve "" as an
execution environment name. This is consistent with the credential
fields above and matches expected UI behavior, but is called out
explicitly here since it wasn't the field originally reported in #14843.
A separate, module-specific fix will still be needed for #14843 itself
(job_template's webhook_credential) and for the related reports on the same
resolver behavior: #15844, #15846, #16167.
ISSUE TYPE
COMPONENT NAME
STEPS TO REPRODUCE AND EXTRA INFO
Before the fix, running the
projectmodule withcredential: ""on aproject that already had a credential set would fail trying to resolve
""as a credential name, instead of clearing the field.Added
test_clear_project_credentialtotest_project.py, which:credential: ''database
Full collection test suite passes (202/202 in
test/awx/), andansible-test sanity --python 3.11passes cleanly on the changed module(
plugins/modules/project.py).