-
Notifications
You must be signed in to change notification settings - Fork 820
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: prevent removal of analytics and auth when being depended on #11210
Conversation
Codecov Report
@@ Coverage Diff @@
## dev #11210 +/- ##
==========================================
+ Coverage 49.36% 49.39% +0.02%
==========================================
Files 678 680 +2
Lines 32692 32723 +31
Branches 6674 6680 +6
==========================================
+ Hits 16138 16163 +25
- Misses 15074 15080 +6
Partials 1480 1480
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be long term.
- Is there a way to declare dependencies at CFN template level for this?
- If not, should we develop a mechanism/pattern where we can declare dependencies between categories in less coupling way ?
packages/amplify-category-analytics/src/commands/analytics/remove.ts
Outdated
Show resolved
Hide resolved
packages/amplify-category-analytics/src/plugin-client-api-notifications.ts
Outdated
Show resolved
Hide resolved
Re your long term concerns @sobolk:
|
let's log this work in backlog then if we haven't already. we should set a threshold when adhoc mechnisms like that prompt the refactoring if we want to avoid complexity explosion. |
Co-authored-by: John Hockett <[email protected]>
throwErrorIfProjectHasAnalytics(meta); | ||
|
||
const hasPossiblyDependentResources = Object.keys(meta) | ||
.some(categoryName => ['api', 'storage', 'function'].includes(categoryName) && Object.keys(meta[categoryName]).length > 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why did analytics get removed from here? Does Analytics not depend on Auth?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now that there's an upstream check to fail if analytics exists, we don't need to warn about it here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was about to ask a question here as well. Why do we have two mechanism for similar problem but they just differ by severity - i.e. one throws the other warns . (perhaps this should go to the long term follow up we should do here at some point).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a good question that I don't know the answer to. I was just trying to keep the behavior change as localized as possible for this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I see what's going on now; not a blocker IMO
f139150
Description of changes
Adds a check in the remove analytics handler to throw if notifications exists (because it depends on analytics) and likewise adds a check in auth remove to throw if analytics exists (because analytics depends on auth). In both cases an error message is printed telling the customer to remove the upstream dependency first, then retry the removal
Issue #, if available
Description of how you validated changes
Manually tested and added a unit tests.
Checklist
yarn test
passesBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.