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

cy.request does not work with followRedirect: false and Set-Cookie in 3.5.0 #5654

Closed
jaroslav-kubicek opened this issue Nov 11, 2019 · 10 comments · Fixed by #5704 · May be fixed by ngChile/ngx-devkit-cypress-builder#20 or qsays/grafana#1
Assignees
Labels
topic: cookies 🍪 type: regression A bug that didn't appear until a specific Cy version release v3.5.0 🐛 Issue present since 3.5.0

Comments

@jaroslav-kubicek
Copy link

jaroslav-kubicek commented Nov 11, 2019

Hi! 👋

We have a test where we want to test redirects, unfortunately it breaks after update to cypress 3.6.1 from 3.3.2:

it('test', () => {
    cy.request({
      url: '/pages/somePage',
      followRedirect: false,
    }).then(resp => {
      expect(resp.status).to.eq(302)
      expect(resp.redirectedToUrl).to.eq("https://example.com/")
    })
})

Error

CypressError: cy.request() failed trying to load:

http://localhost:8000/pages/somePage

We attempted to make an http request to this URL but the request failed without a response.

We received this error at the network level:

  > The "url" argument must be of type string. Received type undefined

Versions

3.6.1

@ZijlkerVR
Copy link

ZijlkerVR commented Nov 11, 2019

This issue was introduced today in 3.6.1. No problems on 3.6.0. Direct requests work fine, but as soon as you start using options and path, it breaks.

This request is broken since 3.6.1:

cy.request({
        url: Cypress.config('baseUrl') + '/auth/realms/' + Cypress.env('shortcode') + '/protocol/openid-connect/auth',
        followRedirect: false,
        qs: {
            scope: 'name,email',
            response_type: 'code',
            approval_prompt: 'auto',
            redirect_uri: Cypress.config('baseUrl') + '/userauth',
            client_id: 'account'
        }
})

When I remove path and either followRedirect or QS the error is gone. Only removing 1 argument or only removing path will result in same error. Obviously I need all to make the request I need.

No path still errors:

cy.request({
        url: Cypress.config('baseUrl'),
        followRedirect: false,
        qs: {
            scope: 'name,email',
            response_type: 'code',
            approval_prompt: 'auto',
            redirect_uri: Cypress.config('baseUrl') + '/userauth',
            client_id: 'account'
        }
})

No path and no one less argument, error gone:

cy.request({
        url: Cypress.config('baseUrl'),
        // followRedirect: false,
        qs: {
            scope: 'name,email',
            response_type: 'code',
            approval_prompt: 'auto',
            redirect_uri: Cypress.config('baseUrl') + '/userauth',
            client_id: 'account'
        }
})

Sorry for the edits. Made some formatting errors.

@jkroepke
Copy link

I can confirm this error.

If followRedirect: false is defined, the error The "url" argument must be of type string. Received type undefined is thrown

@MattFisher
Copy link

Looks like if options.followRedirect is false, currentUrl isn't set within sendPromise before it's used here. (Was changed from options.url in #5478)

@bondar-artem
Copy link

I confirm. Same issue for me in 3.6.1. Version 3.6.0 works fine

@aarontbt
Copy link

Same over here, if I have followRedirect: false defined on 3.6.1 it breaks but not on 3.6.0

@flotwig flotwig self-assigned this Nov 14, 2019
@flotwig flotwig changed the title cy.request does not work with options cy.request does not work with followRedirect: false and Set-Cookie Nov 14, 2019
@flotwig
Copy link
Contributor

flotwig commented Nov 14, 2019

@MattFisher is correct, the error occurs because currentUrl is not set if followRedirect is false.

The bug is even more specific than just followRedirect: false - we definitely have tests for basic usage of followRedirect: false. This bug will only happen if you're setting followRedirect: false and your final redirect has a Set-Cookie header. Updated the title to reflect this.

@flotwig
Copy link
Contributor

flotwig commented Nov 14, 2019

Opened a PR to resolve this: #5704

@cypress-bot cypress-bot bot added stage: needs review The PR code is done & tested, needs review and removed stage: work in progress labels Nov 14, 2019
@cypress-bot cypress-bot bot added stage: pending release and removed stage: needs review The PR code is done & tested, needs review labels Nov 15, 2019
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Nov 15, 2019

The code for this is done in cypress-io/cypress#5704, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

1 similar comment
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Nov 15, 2019

The code for this is done in cypress-io/cypress#5704, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

@jennifer-shehane jennifer-shehane added topic: cookies 🍪 type: regression A bug that didn't appear until a specific Cy version release labels Nov 27, 2019
@jennifer-shehane jennifer-shehane changed the title cy.request does not work with followRedirect: false and Set-Cookie cy.request does not work with followRedirect: false and Set-Cookie in 3.5.0 Nov 27, 2019
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Nov 27, 2019

Released in 3.7.0.

@jennifer-shehane jennifer-shehane added the v3.5.0 🐛 Issue present since 3.5.0 label Dec 10, 2019
@cypress-io cypress-io locked as resolved and limited conversation to collaborators Jan 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
topic: cookies 🍪 type: regression A bug that didn't appear until a specific Cy version release v3.5.0 🐛 Issue present since 3.5.0
Projects
None yet
8 participants