Open psykzz opened 2 years ago
@psykzz Thanks for reporting this issue. I will check and get back to you asap.
@psykzz Can you share the steps to reproduce this issue?
Setup a contentstack stack with two environments, A + B.
Setup a Gatsby site building data from stack B.
Change the access_token and environement from A -> B.
Observe the issue
Thanks @psykzz for sharing the steps. Will check this ASAP.
Any updates on this issue? @vkalta
@abhishek305 Can you please check this and update @psykzz ?
More details and a potential fix can be found in https://github.com/contentstack/gatsby-source-contentstack/pull/116#discussion_r768926000
Hey @psykzz, I will try to reproduce this issue on my end and will update you soon. Thanks again
@abhishek305 Can you please check this and update @psykzz ?
Yes will check
- Setup a contentstack stack with two environments, A + B.
- Setup a Gatsby site building data from stack B.
- Change the access_token and environement from A -> B.
- Observe the issue
Hey @psykzz,
Could please elaborate there seems to be some confusion in step 3 are you talking about setting up 2 stacks or a stack with two environments and also the gatsby site sourcing from 2 stacks?
So I have a stack with multiple environments. I setup and run against environment A, and everything builds fine.
In this case i needed to provide the following configuration
{
api_key: "stack-api-key"
delivery_token: "environment-a-delivery-token"
environment_name: "environment-a"
}
If i then swap to environment B. I replace my config with
{
api_key: "stack-api-key"
delivery_token: "environment-b-delivery-token"
environment_name: "environment-b"
}
After running the 2nd time, i get
{
error_message: 'Failed to fetch items. Please try again with valid parameters.',
error_code: 141,
errors: { access_token: [ 'environment or access token is not matched.' ] }
}
This is because i believe the cached data is only keyed by the api_key and so changing the delivery token attempts to use the old cache, which in this case is wrong, leading to the error message.
So I have a stack with multiple environments. I setup and run against environment A, and everything builds fine.
In this case i needed to provide the following configuration
{ api_key: "stack-api-key" delivery_token: "environment-a-delivery-token" environment_name: "environment-a" }
If i then swap to environment B. I replace my config with
{ api_key: "stack-api-key" delivery_token: "environment-b-delivery-token" environment_name: "environment-b" }
After running the 2nd time, i get
{ error_message: 'Failed to fetch items. Please try again with valid parameters.', error_code: 141, errors: { access_token: [ 'environment or access token is not matched.' ] } }
This is because i believe the cached data is only keyed by the api_key and so changing the delivery token attempts to use the old cache, which in this case is wrong, leading to the error message.
Hi @psykzz, I tried to reproduce the error from the steps you've given but was unable to reproduce this on my end. Steps I performed:
Could you please update the source plugin version and try it once also if possible could you share a few details?
let me know what is observed after the update Thanks !!
Once setup, if you change environment (but keeping the same key) you will get the following error.
Looks like we just need to include the environment + api_key in the cache key.