Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

[Bug] Switching environments will re-use a stale chained request value #669

Closed
qJake opened this issue Dec 18, 2017 · 15 comments
Closed

[Bug] Switching environments will re-use a stale chained request value #669

qJake opened this issue Dec 18, 2017 · 15 comments

Comments

@qJake
Copy link

qJake commented Dec 18, 2017

  • Insomnia Version: 5.12.4
  • Operating System: Windows 10 Pro (10.0.16299.125)

Details

If a workspace contains a chained request value (e.g. a bearer token) and there is more than one environment (e.g. development and staging), if a request is executed in development that requires a chained request value, that value will persist if switching to the other environments.

Steps to Reproduce

  1. Create "Development" environment
  2. Create "Staging" environment
  3. Create POST request which retrieves OAuth 2.0 Bearer token
  4. Create GET request which requires Authorization: Bearer <token> header
  5. Fill Auth Bearer Token value with Response => Body Attribute macro, executing the POST Token request from Step 3.
  6. Execute request, and ensure bearer token was used in the request successfully
  7. Switch environments
  8. Execute the same request. Note that the previous bearer token was cached and used as part of the request (and, presumably, you will get either a 400 Bad Request or 401 Unauthorized error).
@welcome
Copy link

welcome bot commented Dec 18, 2017

👋 Thanks for opening your first issue! If you're reporting a 🐞 bug, please make sure
you include steps to reproduce it. If you're requesting a feature 🎁, please provide real
use cases that would benefit. 👪

To help make this a smooth process, please be sure you have first read the
contributing guidelines.

@gschier
Copy link
Contributor

gschier commented Dec 18, 2017

Hi @qJake, thanks for the great issue report!

To clarify, this is not a bug but a limitation of the feature. The Response => Body Attribute simply pulls the value from the latest response of that request, meaning it has no concept of environments.

I think this can actually be treated as a larger issue with environments in general. Perhaps environments should affect the user's workflow more than they do? For example, only showing responses sent using the currently-active environment would prevent this from being an issue and possibly even be the desired outcome.

P.S. This does not solve the problem, but I'm curious... How come you are not using the official OAuth 2.0 support?

@qJake
Copy link
Author

qJake commented Dec 19, 2017

We interface with a custom third-party API we don't control, and they don't implement "proper" OAuth 2.0. I wish we could use it. 😄

I'm curious - you said it only pulls the last response from the referenced request - if there is no response, does it execute that request first in the background?

If so, would it be possible to just delete the "cache" upon an environment switch, so to speak? Or would that mess up some other use cases for environments...?

If it helps, I consider an environment an isolated entity - I would not want my staging responses being used in development, or worse, my production responses used somewhere else inadvertently. (Granted, this is just a random bearer token, but still.) We also use the environment switcher for accessing different client servers occasionally (we're talking a dozen or so, sometimes less) - so obviously any persistent data between those environments could present a problem (at the very least, auth won't work, as I reported ⏫).

For what it's worth, we just switched from Postman and I'm already loving Insomnia a lot more, so keep up the great work!

@stale
Copy link

stale bot commented Feb 17, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale Bot: Stale Issue label Feb 17, 2018
@qJake
Copy link
Author

qJake commented Feb 19, 2018

Could this be marked as an enhancement for future work on environments? I just don't want it to get closed - I think it's still a viable addition to Insomnia!

@stale stale bot removed the stale Bot: Stale Issue label Feb 19, 2018
@devinsba
Copy link

I just ran into this using the official OAuth 2 support, it was completely unexpected. I certainly would like the "responses from one environment not available in another" feature. Would love to see that

@stale
Copy link

stale bot commented Apr 20, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale Bot: Stale Issue label Apr 20, 2018
@qJake
Copy link
Author

qJake commented Apr 23, 2018

Bad stale bot! Bad!

Paging @gschier - can we switch this to an enhancement request so it doesn't get closed? Would love to see this functionality improve in future versions!

@stale stale bot removed the stale Bot: Stale Issue label Apr 23, 2018
@gschier
Copy link
Contributor

gschier commented Apr 23, 2018

Yep, now it won't close 😄

@jmillxyz
Copy link

jmillxyz commented May 4, 2018

FWIW I just ran into the same issue -- we use bearer JWT tokens with multiple environments (dev, staging, prod, etc) and tokens are generated by scoping them to a single environment. Caching them across environments in my case was unexpected. What's the best way for us to help with this @gschier ?

@stale
Copy link

stale bot commented May 3, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale Bot: Stale Issue label May 3, 2019
@qJake
Copy link
Author

qJake commented May 8, 2019

Bad bot! No stale tag! This is still something I'd love to see - essentially having the history / response cache be per-environment instead of global. Would have numerous benefits!

@stale stale bot removed the stale Bot: Stale Issue label May 8, 2019
@gschier
Copy link
Contributor

gschier commented May 8, 2019

Sorry about that. I was changing up the issue tag descriptions so the stale bot went on a rampage!

@qJake
Copy link
Author

qJake commented May 24, 2019

I have a follow-up suggestion to this that may work or be a bit easier to implement with regards to the suggestion above...

I noticed a new feature, Trigger Behavior, on the Response function. Would it be possible to add a new Trigger Behavior called "On Environment Change" that would cause the request to re-execute if the user switched environments? This would satisfy my previous concern about cross-contaminating environments and auth tokens.

Thoughts?

@fcottet
Copy link

fcottet commented May 4, 2020

This is very similar to issue #260
It would be awesome to see these 2 questions solved in a similar manner - like an option at the workspace level to reset all the stored responses/tokens when switching between environments.

@wdawson wdawson closed this as completed Jun 30, 2021
@Kong Kong locked and limited conversation to collaborators Jun 30, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants