Skip to content

Fix --reset flag regression: skip spurious TOML selection prompt before link flow#7238

Open
timothytenzin20 wants to merge 7 commits intomainfrom
04-08-fix_reset_spurious_toml_selection_prompt
Open

Fix --reset flag regression: skip spurious TOML selection prompt before link flow#7238
timothytenzin20 wants to merge 7 commits intomainfrom
04-08-fix_reset_spurious_toml_selection_prompt

Conversation

@timothytenzin20
Copy link
Copy Markdown

@timothytenzin20 timothytenzin20 commented Apr 9, 2026

Bug

Bug 1: shopify app dev --reset spuriously prompts TOML file selection before the reset flow (org → app → config name). The selected TOML is immediately discarded.

Bug 2: shopify app config link --client-id=x prompts for a config name when no TOML files exist, instead of using the default shopify.app.toml.

Fixes shop/issues-develop#22531 and https://community.shopify.dev/t/shopify-app-config-link-client-id-prompts-for-config-name/33039

Root Cause

Bug 1 (--reset)

Regression introduced by #6612 ("Remove legacy app schema", merged Mar 2026). Commit 1f8dcceaec ("Simplify code") merged the forceRelink and !isLinked branches back together, undoing a prior fix from #5676 (Apr 2025) which fixed #5653 by separating the forceRelink path so it skips config state loading.

getAppConfigurationContext() is called unconditionally before checking forceRelink. When the cached config file doesn't exist on disk, it calls selectConfigFile(), prompting the user to pick a TOML — even though forceRelink will discard the result.

Bug 2 (config link --client-id)

In loadConfigurationFileName(), when no existing TOML matches the remote app's API key, the code falls through to selectConfigName() which prompts the user — even when there are zero TOML files and the obvious default is shopify.app.toml.

Fix

  1. app-context.ts — Separate the forceRelink and !isLinked paths so forceRelink skips getAppConfigurationContext() entirely and calls link() directly.
  2. link.ts / loader.ts / active-config.ts — Thread a skipPrompts option through link()loadApp() / loadOpaqueApp()getAppConfigurationContext()selectActiveConfig() so that the stale-cache prompt is also skipped when called from inside the link flow.
  3. link.ts — When no TOML files exist at all, use the default shopify.app.toml without prompting.

Test

  • Added test verifying getAppConfigurationContext is only called after link() when forceRelink is true (using invocationCallOrder tracking).
  • Added test verifying selectConfigName is not called when no TOML files exist.

All 24 tests pass ✅

🎩

Expected Results:

shopify app dev --reset

Using latest:

Screenshot 2026-04-10 at 3 07 28 PM

Using snapshot (0.0.0-snapshot-20260413221738):

Screenshot 2026-04-14 at 10 28 04 AM

shopify app config link --client-id=<your-client-id>

Using latest:

Screenshot 2026-04-14 at 10 30 04 AM

Using snapshot (0.0.0-snapshot-20260413221738):

image

Setup

Navigate to any Shopify app directory that has multiple shopify.app.*.toml files, then delete the currently cached/active TOML so the stale-cache path is triggered.

Warning

Make sure to double check the version change is working by using
which shopify && shopify version
If the version is not changing use these commands:
pnpm remove -g @shopify/cli
pnpm add -g @shopify/cli@[version]
which shopify && shopify version

1. Reproduce the --reset bug (@latest)

pnpm i -g --@shopify:registry=https://registry.npmjs.org @shopify/cli@latest
shopify app dev --reset --path /path/to/your/app

Expected (broken): You get prompted to select a TOML file before the org → app → config name flow. The selection is immediately discarded.

2. Reproduce the config link bug (@latest)

pnpm i -g --@shopify:registry=https://registry.npmjs.org @shopify/cli@latest
cd /path/to/app/with/no/toml/files
shopify app config link --client-id=<your-client-id>

Expected (broken): You get prompted for "Configuration file name:" (or an error in non-interactive mode).

3. Verify both fixes (snapshot)

pnpm i -g --@shopify:registry=https://registry.npmjs.org @shopify/cli@0.0.0-snapshot-20260413221738
# Test --reset
shopify app dev --reset --path /path/to/your/app
# Test config link (remove any TOMLs first)
shopify app config link --client-id=<your-client-id>

Expected (fixed):

  • --reset goes straight into the org → app → config name flow with no spurious TOML selection prompt.
  • config link --client-id creates shopify.app.toml without prompting for a name.

@timothytenzin20 timothytenzin20 requested review from a team as code owners April 9, 2026 21:02
Copy link
Copy Markdown
Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@gonzaloriestra
Copy link
Copy Markdown
Contributor

/snapit

@github-actions
Copy link
Copy Markdown
Contributor

🫰✨ Thanks @gonzaloriestra! Your snapshot has been published to npm.

Test the snapshot by installing your package globally:

npm i -g --@shopify:registry=https://registry.npmjs.org @shopify/cli@0.0.0-snapshot-20260410122533

Caution

After installing, validate the version by running shopify version in your terminal.
If the versions don't match, you might have multiple global instances installed.
Use which shopify to find out which one you are running and uninstall it.

Copy link
Copy Markdown
Contributor

@gonzaloriestra gonzaloriestra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! The fix makes sense, but I think something is not working. I'm still getting the config prompt when running pnpm shopify app info --reset after deleting the current TOML and having multiple ones.

I think what's missing is to avoid it from link. In 04-08-fix_reset_spurious_toml_selection_prompt_2 I added the missing pieces. Still have to review and test more, but it seems to work. Feel free to add here the changes from there if you want.

@timothytenzin20
Copy link
Copy Markdown
Author

/snapit

@github-actions
Copy link
Copy Markdown
Contributor

🫰✨ Thanks @timothytenzin20! Your snapshot has been published to npm.

Test the snapshot by installing your package globally:

npm i -g --@shopify:registry=https://registry.npmjs.org @shopify/cli@0.0.0-snapshot-20260410185310

Caution

After installing, validate the version by running shopify version in your terminal.
If the versions don't match, you might have multiple global instances installed.
Use which shopify to find out which one you are running and uninstall it.

@timothytenzin20
Copy link
Copy Markdown
Author

@gonzaloriestra thanks for the feedback, i made the changes and added tophatting results/steps

@gonzaloriestra
Copy link
Copy Markdown
Contributor

@timothytenzin20 would you mind having a look at https://community.shopify.dev/t/shopify-app-config-link-client-id-prompts-for-config-name/33039? It's very related, but this PR doesn't fix that. Now that you have context, maybe it's an easy change to add here 🙏

A quick way to test it:

  • Remove all the app TOMLs (copy a client ID first)
  • Run shopify app config link --client-id=x
  • It shouldn't ask for the config name, but just use the default one (shopify.app.toml)

@timothytenzin20
Copy link
Copy Markdown
Author

timothytenzin20 commented Apr 13, 2026

TODO: look into shopify app dev failing to get the Cloudflare tunnel.

  • shopify app dev hanging

@timothytenzin20 timothytenzin20 force-pushed the 04-08-fix_reset_spurious_toml_selection_prompt branch from 0d0c247 to 8ffd3ba Compare April 13, 2026 22:05
@timothytenzin20
Copy link
Copy Markdown
Author

/snapit

@github-actions
Copy link
Copy Markdown
Contributor

🫰✨ Thanks @timothytenzin20! Your snapshot has been published to npm.

Test the snapshot by installing your package globally:

npm i -g --@shopify:registry=https://registry.npmjs.org @shopify/cli@0.0.0-snapshot-20260413221738

Caution

After installing, validate the version by running shopify version in your terminal.
If the versions don't match, you might have multiple global instances installed.
Use which shopify to find out which one you are running and uninstall it.

@timothytenzin20
Copy link
Copy Markdown
Author

@gonzaloriestra the change was made for running shopify app config link --client-id=x, please test and review

Copy link
Copy Markdown
Contributor

@gonzaloriestra gonzaloriestra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking care of the other issue as well! It works as expected 👌

@timothytenzin20
Copy link
Copy Markdown
Author

Investigation: Cloudflare tunnel not used after config link

(Posted by Claude on behalf of @timothy.khan)

cc @kbav for visibility

During testing, we noticed that after running shopify app config link --client-id=..., subsequent shopify app dev runs no longer used Cloudflare tunnel (showed Using URL: https://shopify.dev/apps/default-app-home instead of a .trycloudflare.com URL).

Root cause: config link generates a new TOML from remote config, which doesn't include the [build] section since automatically_update_urls_on_dev is a local-only setting (never stored in Partners).

Why this is correct behavior:

  • config link is designed to sync with remote config, not preserve local-only settings
  • The [build] section is intentionally local-only
  • shopify app dev is responsible for prompting about URL update preferences and persisting them to the TOML

Expected workflow:

  1. config link --client-id=... → creates TOML from remote (no [build] section)
  2. shopify app dev → prompts "Have Shopify override your app URLs?" → user answers → saves automatically_update_urls_on_dev to TOML
  3. Subsequent dev runs use the saved preference

This separation of concerns is correct - no changes needed.

Copy link
Copy Markdown
Contributor

kbav commented Apr 14, 2026

@timothytenzin20 This bit:

shopify app dev → prompts "Have Shopify override your app URLs?" → user answers → saves automatically_update_urls_on_dev to TOML

So do you think you had answered "no" on this ? Is that why it wasn't working on your machine?

@timothytenzin20 timothytenzin20 added this pull request to the merge queue Apr 14, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Apr 14, 2026
@timothytenzin20
Copy link
Copy Markdown
Author

So do you think you had answered "no" on this ? Is that why it wasn't working on your machine?

Yea I believe so. I recall having pressed it one of my many iterations. That probably was just the most recent one when we tried to shopify app dev during our pair 😞

@timothytenzin20 timothytenzin20 added this pull request to the merge queue Apr 14, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Apr 14, 2026
@timothytenzin20 timothytenzin20 force-pushed the 04-08-fix_reset_spurious_toml_selection_prompt branch from a75fc9f to 1370036 Compare April 14, 2026 21:18
timothytenzin20 and others added 2 commits April 15, 2026 10:53
…re link flow

When running `shopify app dev --reset`, `getAppConfigurationContext()` was
called unconditionally before checking `forceRelink`. If the cached config
file didn't exist on disk, this triggered `selectConfigFile()`, prompting
the user to pick a TOML file that would be immediately discarded by `link()`.

Regression introduced by #6612 ("Remove legacy app schema", commit 1f8dcce)
which merged the forceRelink and !isLinked branches back together, undoing
the prior fix from #5676.

Fix: separate the two paths so forceRelink skips `getAppConfigurationContext()`
entirely and calls `link()` directly.

Fixes shop/issues-develop#22531
@gonzaloriestra gonzaloriestra force-pushed the 04-08-fix_reset_spurious_toml_selection_prompt branch from 1370036 to 45117ed Compare April 15, 2026 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: app deploy --reset no longer resets toml file configuration

3 participants