Add notification-driven kill switch for auto-upgrade#7422
Merged
Conversation
986730c to
45bcc7a
Compare
45bcc7a to
e53a12a
Compare
e53a12a to
e14c9f7
Compare
e14c9f7 to
c8123b6
Compare
Contributor
Differences in type declarationsWe detected differences in the type declarations generated by Typescript for this branch compared to the baseline ('main' branch). Please, review them to ensure they are backward-compatible. Here are some important things to keep in mind:
New type declarationsWe found no new type declarations in this PR Existing type declarationspackages/cli-kit/dist/public/node/upgrade.d.ts@@ -22,6 +22,18 @@ export declare function runCLIUpgrade(): Promise<void>;
* @returns The version string to upgrade to, or undefined if no upgrade should happen.
*/
export declare function versionToAutoUpgrade(): string | undefined;
+/**
+ * Checks the freshly fetched notifications feed for a kill-switch notification that
+ * disables auto-upgrade. A blocking notification is one with ,
+ * , and matching version/date ranges for the current CLI.
+ *
+ * Fails open: any error fetching or parsing the feed results in , so a broken
+ * notifications endpoint never prevents users from auto-upgrading. Intentionally silent
+ * (no logs) — this is invoked on the auto-upgrade hot path.
+ *
+ * @returns when an active blocking notification is found, otherwise.
+ */
+export declare function hasBlockingAutoUpgradeNotification(): Promise<boolean>;
/**
* Shows a daily upgrade-available warning for users who have not enabled auto-upgrade.
* Skipped in CI and for pre-release versions. When auto-upgrade is enabled this is a no-op
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

WHY are these changes introduced?
We need a remote kill switch for CLI auto-upgrade so we can stop a bad release from being silently rolled out further while a fix is in flight. Today, once a user has opted into auto-upgrade, every postrun will attempt to upgrade to the latest cached version with no way for us to halt that flow short of unpublishing.
This PR reuses the existing notifications system as the transport for that kill switch: an
error-type notification on a newautoupgradesurface silently disables the auto-upgrade for matching CLI versions / date windows.WHAT is this pull request doing?
hasBlockingAutoUpgradeNotification()inpackages/cli-kit/src/public/node/upgrade.ts. It freshly fetches the notifications feed (no cache) and returnstrueiff there is at least one notification withsurface === 'autoupgrade',type === 'error', and matchingmin/maxVersion+min/maxDate. Lives in the upgrade module rather than the notifications module because the policy (which surface, which type counts as blocking) is auto-upgrade specific.autoUpgradeIfNeeded'sperformAutoUpgradepath. The check runs after every existing gate — cached newer version, opt-in, not CI, not pre-release, daily rate limit /SHOPIFY_CLI_FORCE_AUTO_UPGRADE— so:outputWarn/outputInfo) andenv_auto_upgrade_skipped_reason: 'blocked_by_notification'is recorded for analytics.false, with no logging, so a broken notifications endpoint never prevents upgrades.How to test your changes?
Locally simulate a kill-switch notification and verify that auto-upgrade is silently skipped:
{ "id": "block-autoupgrade", "message": "Auto-upgrade temporarily disabled", "type": "error", "frequency": "always", "ownerChannel": "#cli", "surface": "autoupgrade" }export SHOPIFY_CLI_NOTIFICATIONS_URL=....export SHOPIFY_CLI_FORCE_AUTO_UPGRADE=1, with auto-upgrade enabled, on a version older than the latest published@shopify/cli.upgrade/ non-notificationsShopify CLI command.Expected: no upgrade is performed, no warning/info output is shown, and analytics show
env_auto_upgrade_skipped_reason=blocked_by_notification. Removing the notification (or changingtypetowarning) should let the upgrade proceed as before.Unit tests:
Post-release steps
None.
Checklist
env_auto_upgrade_skipped_reason: 'blocked_by_notification'.