Skip to content
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 the theme ID mismatch error, where the live theme ID is returned instead of the development theme ID #4759

Merged
merged 2 commits into from
Oct 31, 2024

Conversation

karreiro
Copy link
Contributor

@karreiro karreiro commented Oct 28, 2024

WHY are these changes introduced?

Fixes #4634

When the "Sign in with Shop" is activated, the /account endpoint behaves differently (returning the live theme ID in the body) impacting the proxy. However, following the redirect maintains the expected theme ID in the session.

It's important to note that stores without that feature were not being affected by this, and are not affected by this change as well.

WHAT is this pull request doing?

This PR updates the proxy logic to proxy /account requests and avoid the remote-render of the /account endpoint.

This PR also refactors the logic in the proxy to rely on regular expressions to evaluate patterns to centralize the logic for each case on the regular expressions and prevent conditions from growing like p.startsWith(..) && p.endsWith(..).

How to test your changes?

  • Run shopify theme dev in a store with "Sign in with Shop" is activated
  • Open http://127.0.0.1:9292/account in the browser
  • Notice the mismatch error no longer happens

Before
before

After
after

Post-release steps

N/A

Measuring impact

How do we know this change was effective? Please choose one:

  • n/a - this doesn't need measurement, e.g. a linting rule or a bug-fix
  • Existing analytics will cater for this addition
  • PR includes analytics changes to measure impact

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes

@karreiro karreiro requested review from a team as code owners October 28, 2024 12:13
@karreiro karreiro requested a review from jamesmengo October 28, 2024 12:13
Copy link
Contributor

github-actions bot commented Oct 28, 2024

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements
72.44% (+0.01% 🔼)
8365/11548
🟡 Branches
68.83% (+0.02% 🔼)
4077/5923
🟡 Functions 71.87% 2197/3057
🟡 Lines
72.74% (+0.01% 🔼)
7911/10876

Test suite run success

1919 tests passing in 872 suites.

Report generated by 🧪jest coverage report action from ec245ae

@EvilGenius13
Copy link
Contributor

Thank you for the fix @karreiro 🥳 . I 🎩 and it works for me as well.

Copy link
Contributor

@jamesmengo jamesmengo left a comment

Choose a reason for hiding this comment

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

left 1 suggestion for test name brevity. non blocking

@jamesmengo
Copy link
Contributor

This fixes the issue with the server crashing

Aside - clicking sign in with shop opens the modal but doesn't populate any content there. Is this expected?
image

@karreiro
Copy link
Contributor Author

/snapit

Copy link
Contributor

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

Test the snapshot by intalling your package globally:

pnpm i -g @shopify/[email protected]

After installing, validate the version by running just shopify 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.

@karreiro
Copy link
Contributor Author

Thank you for the review, everyone!

Aside - clicking sign in with shop opens the modal but doesn't populate any content there. Is this expected?

I was thinking the same thing, @jamesmengo. Currently, that's expected — that's a different limitation in the proxy, as pay.shopify.com won't accept requests from http://127.0.0.1:9292. I think it's reasonable to revisit this in the future, but at the moment, I believe there are workflows in the main path of the CLI that need more attention.

@karreiro karreiro added this pull request to the merge queue Oct 31, 2024
Merged via the queue into main with commit 77562f0 Oct 31, 2024
@karreiro karreiro deleted the theme-id-mismatch branch October 31, 2024 13:37
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]: Theme ID mismatch – Live theme ID returned instead of development theme
5 participants