Conversation
…g PATCH When a credential has an input_source (e.g. HashiCorp Vault) attached to a field, get_input() unconditionally delegates to the external backend — even when a direct value is being provided via PATCH. This causes HTTP 500 if the backend is unreachable, or silently discards the new value if it is reachable. Fix get_input() to check for a non-placeholder direct value in self.inputs before falling through to _get_dynamic_input(). This lets PATCH requests override an externally-sourced field without triggering a live call to the external credential backend. Co-authored-by: Cursor <cursoragent@cursor.com>
|
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 (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthrough
ChangesCredential input resolution
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to PATCH requests can now use a supplied direct credential value while credentials without an override continue using the external source; no actionable merge-blocking risk remains after normal checks and review. Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Credential.get_input()unconditionally delegates to the external credential backend (e.g. HashiCorp Vault) when aninput_sourceis attached, even when a direct value is being provided via PATCH.self.inputsbefore falling through to_get_dynamic_input(), allowing PATCH requests to override externally-sourced fields.Issue
AAP-89036
Root Cause
In
awx/main/models/credential.py,get_input()checksdynamic_input_fieldsfirst and always routes to_get_dynamic_input()which makes a live network call to the external backend. There was no guard to check whether a direct value was being supplied in an update context.Changes
awx/main/models/credential.py: Modifiedget_input()to check if a direct (non-placeholder) value exists inself.inputsbefore delegating to the dynamic input source. If a direct value is present, it is returned (with decryption for secret fields), bypassing the external backend call.awx/main/tests/functional/test_credential.py: Added two regression tests:test_get_input_prefers_direct_value_over_dynamic_source— verifies direct values take precedencetest_get_input_falls_back_to_dynamic_when_no_direct_value— verifies the dynamic path still works when no direct value is presentTest plan
ssh_key_data— should succeed without contacting VaultMade with Cursor
Summary by CodeRabbit
Bug Fixes
Tests