fix: prevent dry-run crash on clientAuthCredentials handler - #1438
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1438 +/- ##
==========================================
+ Coverage 80.35% 80.36% +0.01%
==========================================
Files 163 163
Lines 7589 7595 +6
Branches 1676 1677 +1
==========================================
+ Hits 6098 6104 +6
Misses 797 797
Partials 694 694 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| // dryRunChanges on every handler) does not crash. Credential changes are still applied | ||
| // during a real import via processChanges. | ||
| async dryRunChanges(_assets: Assets): Promise<CalculatedChanges> { | ||
| return { del: [], create: [], conflicts: [], update: [] }; |
There was a problem hiding this comment.
This silently hides credential changes from the dry-run preview, if a user's config adds or removes client_authentication_methods, dry-run will show no diff but the real import will still apply those changes
That's misleading for anyone using dry-run to audit before deploying
The crash fix is correct and good to merge. Worth tracking a follow-up to surface actual credential diffs in the preview
There was a problem hiding this comment.
Agreed! This is a known, intentional trade-off of the crash fix (called out in the PR description and the code comments): credential changes aren't itemized in the dry-run preview yet, though a real import still applies them. I'll open an internal follow-up for this!
🔧 Changes
Fixes a crash during
import --dry_runthat aborted the entire dry-run preview withhandler.dryRunChanges is not a function.The
clientAuthCredentialsfeature added two handlers that were implemented for the deploy path only and did not define adryRunChanges()method. Because the dry-run engine callsdryRunChanges()on every registered handler, the run crashed as soon as it reached this resource - regardless of whether the tenant actually used client credentials.dryRunChanges()method toClientAuthCredentialsHandlerandClientAuthCredentialsPreHandler, each returning empty changes ({ del: [], create: [], conflicts: [], update: [] }) - the same no-op shape the base handler returns when there is nothing to do.import.dryRunChanges(with a warning) instead of crashing, so a future deploy-only handler can't reintroduce this failure.import(without--dry_run) was never affected.No changes to the YAML/JSON config shape - the
clientAuthCredentials/client_authentication_methodsstructure is unchanged. This only affects dry-run behavior.🔭 Future scope
🔬 Testing
Unit Test
dryRunChanges, so a non-conforming handler is caught at build time.Manual:
a0deploy import --input_file=./tenant.yaml --dry_runnow completes on a tenant with client credentials instead of crashing.📝 Checklist