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

Prefer header kept for subsecuent requests #1071

Closed
r1ckr opened this issue Mar 31, 2020 · 7 comments · Fixed by #1074
Closed

Prefer header kept for subsecuent requests #1071

r1ckr opened this issue Mar 31, 2020 · 7 comments · Fixed by #1074
Labels

Comments

@r1ckr
Copy link

r1ckr commented Mar 31, 2020

Describe the bug
I am following the following documentation to select what example I want when making a request:
https://stoplight.io/p/docs/gh/stoplightio/prism/docs/guides/01-mocking.md#response-examples

When I specify the Prefer: example=<my example name>; header it returns the requested example, but prism caches the header and all the subsequent requests without it will try to get that example.

To Reproduce
If I have following 2 paths:

/my-path
  examples:
    example1: <my example here>
    example2: <my example here>
/my-other-path
  examples:
    another-example-name: <my example here>

Making a call to /my-path with header Prefer: example=example1; it will return the specified example with no issues.

If I make a call to /my-other-path without the prefer header, it will return this:

{"type":"https://stoplight.io/prism/errors#NOT_FOUND","title":"The server cannot find the requested content","status":404,"detail":"Response for contentType: application/json and exampleKey: example1 does not exist."}

It's like after making a call with the Prefer header, all the subsequent calls without it, will assume that I want the example1.

Expected behavior
I am expecting that when I don't specify the Prefer header, it returns the first example, as it is specified in the documentation.

This used to work with version 3.2.9

Environment:

  • Library version: 3.3.2
  • OS: Alpine Linux v3.11, macOS

Additional context
I am using your docker containers and locally in my mac, both fail

@r1ckr r1ckr added the bug label Mar 31, 2020
@XVincentX
Copy link
Contributor

XVincentX commented Mar 31, 2020

Hey @r1ckr,

that is really weird, since Prism does not have any caching mechanism at all. Can you share the full document you are using so I can have a deep look into?

Also, what Http client are you using? I suspect that it might be sending the header again, while you probably do not want that.

Can you reproduce the same issue with curl?

@Michael-Dawkins
Copy link

I have encountered the exact same problem today.
As soon as one request has the "Prefer": "example=example-1" header set, the subsequent requests to other endpoints give me an error because they do not have an "example-1".

I have tried specifying "Prefer": "dynamic=true" on the subsequent requests to try and "reset" the behaviour but it did not work.

Library: "@stoplight/prism-cli": "^3.3.2"
OS: MacOS 10.15.3

@Michael-Dawkins
Copy link

I have just tried with @stoplight/prism-cli@3.2.9 but I have the same issue.

@lehphyro
Copy link
Contributor

lehphyro commented Apr 1, 2020

This happens to me as well using curl.

@XVincentX
Copy link
Contributor

@Michael-Dawkins @lehphyro Can you provide a sample document?

@lehphyro
Copy link
Contributor

lehphyro commented Apr 1, 2020

@XVincentX you can use the one attached to #1073

@XVincentX
Copy link
Contributor

Can you try this branch? #1074

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants