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鈥檒l 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
Closed
Assignees
Labels
topic: cookies 馃崻 type: regression v3.5.0 馃悰

Comments

@jaroslav-kubicek
Copy link

@jaroslav-kubicek 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 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

@jkroepke jkroepke commented Nov 11, 2019

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

@MattFisher MattFisher commented Nov 12, 2019

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)

@Postavshik
Copy link

@Postavshik Postavshik commented Nov 13, 2019

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

@aarontbt
Copy link

@aarontbt aarontbt commented Nov 14, 2019

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
Member

@flotwig 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
Member

@flotwig flotwig commented Nov 14, 2019

Opened a PR to resolve this: #5704

@cypress-bot cypress-bot bot added stage: 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 labels Nov 15, 2019
@cypress-bot
Copy link

@cypress-bot 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

@cypress-bot 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 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

@cypress-bot cypress-bot bot commented Nov 27, 2019

Released in 3.7.0.

@cypress-bot cypress-bot bot removed the stage: pending release label Nov 27, 2019
@jennifer-shehane jennifer-shehane added the v3.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 v3.5.0 馃悰
Projects
None yet
8 participants