bigcommerce / stencil-cli

BigCommerce Stencil emulator for local theme development
https://developer.bigcommerce.com/stencil-docs
BSD 4-Clause "Original" or "Old" License
103 stars 140 forks source link

fix: STRF-11923 - Handle Missing a New Channels Permission Requirement in Auth Token #1191

Closed bc-jz closed 3 months ago

bc-jz commented 3 months ago

What?

This PR handles the possibility of missing the Channels auth permission when making a GET for a list of channels in getStoreChannels().

When this update was made I overlooked that the standard Stencil CLI auth token that we recommend providing to 3rd parties does not include the "read channel settings" permission by default. So people utilizing the Stencil CLI token, or any v3 token that does not include "read/manage channel settings" permission, can end up with this error when making start, push, pull, or download commands:

Screenshot 2024-04-10 at 7 14 28 AM

We will be updating that permission on the Stencil CLI token but people with errors will still have to generate a new token to get this permission. As such, this PR will avoid failures if the Channels permission is missing. Instead we will ignore the error and return an unfiltered list of urls the same way we did prior to the change in version 4.7.2.

Refactor Also incorporates some smart improvements to the fetching of channels that I found in this PR: https://github.com/bigcommerce/stencil-cli/pull/1187

Tickets / Documentation

Previous related pr.

Screenshots (if appropriate)

With this changes in this PR we will now give a "warning" message if the "channels" permission is missing and still proceed with an unfiltered response as we did before:

Screenshot 2024-04-10 at 7 17 32 AM

However, if you do have an updated token that includes the correct permission then we will filter the list of channels returned using this new information:

Screenshot 2024-04-10 at 7 19 12 AM

cc @bigcommerce/storefront-team

github-actions[bot] commented 3 months ago

:tada: This PR is included in version 7.5.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket: