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

RequestError: Error: Invalid URI "/runs" #5053

Closed
jennifer-shehane opened this issue Aug 28, 2019 · 4 comments
Closed

RequestError: Error: Invalid URI "/runs" #5053

jennifer-shehane opened this issue Aug 28, 2019 · 4 comments
Labels
pkg/server This is due to an issue in the packages/server directory type: bug

Comments

@jennifer-shehane
Copy link
Member

jennifer-shehane commented Aug 28, 2019

Current behavior:

There is a situation where someone can receive RequestError: Error: Invalid URI "/runs" on POST /runs

The request fails on 4 retries and then bails on recording and runs the tests without recording.

CYPRESS_ENV environment variable is not being set, which was our initial suspicion on the problem. #1621

Important bit of the logs from cypress run --record:

cypress:server:api request to url: POST /runs with params: {
  "body":{
    "ci":{
      "params":{
        "buildId":"123",
        "buildUrl":"https://buildurl",
        "buildNumber":"123"
      },
      "provider":"jenkins"
    },
    "specs":[..removed..],
    "commit":{
      "sha":"123",
      "branch":null,
      "authorName":"..removed..",
      "authorEmail":"..removed..",
      "message":"..removed..",
      "remoteOrigin":"https://remoteorigin",
      "defaultBranch":null
    },
    "group":null,
    "platform":{
      "osCpus":[..removed..],
      "osVersion":"Debian - 9.6",
      "browserName":"Electron",
      "browserVersion":"61.0.3163.100"
    },
    "parallel":null,
    "ciBuildId":null,
    "projectId":"123abc",
    "recordKey":"****",
    "specPattern":null
  },
  "headers":{
    "x-route-version":"4",
    "x-os-name":"linux",
    "x-cypress-version":"3.4.0"
  }
}
We encountered an unexpected error talking to our servers.

We will retry 3 more times in 30 seconds...

The server's response was:

RequestError: Error: Invalid URI "/runs"

It seems like some issue with routes.js and api.coffee not prepending the api url correctly for some reason, since /runs is not the full uri it should be.

Dug into the request library where they send the Invalid URI error here: Was digging into why request would throw an Invalid URI error here: https://github.com/request/request/blob/df346d8531ac4b8c360df301f228d5767d0e374e/request.js#L260

@jennifer-shehane jennifer-shehane added type: bug stage: investigating Someone from Cypress is looking into this pkg/server This is due to an issue in the packages/server directory labels Aug 28, 2019
@jennifer-shehane
Copy link
Member Author

Ran this locally on a project that does record properly to verify what the normal behavior is of this POST:

cypress:server:api request to url: POST https://api.cypress.io/runs with params:

@jennifer-shehane
Copy link
Member Author

Feel like we should be catching null or malformed urls earlier, before we send out the request, maybe here:

https://github.com/cypress-io/cypress/blob/develop/packages/server/lib/util/routes.js#L52

@jennifer-shehane
Copy link
Member Author

If I run cypress run above with CYPRESS_ENV or CYPRESS_KONFIG_ENV set, then I get this exact error about invalid URI:

CYPRESS_ENV='https://foo' DEBUG=cypress:server:api cypress run --record --key ***
  cypress:server:api request to url: POST /runs with params: {..} and token: undefined +0ms
We encountered an unexpected error talking to our servers.

We will retry 3 more times in 30 seconds...

The server's response was:

RequestError: Error: Invalid URI "/runs"

@jennifer-shehane
Copy link
Member Author

Turns out the CYPRESS_ENV was unexpectedly set in this case, so I will be closing this as a duplicate of #1621

If you are facing this issue

To check that you do not have an environment variable set with the name CYPRESS_ENV or CYPRESS_KONFIG_ENV on the system that cypress run is running - run this on that system.

env | grep -E "(CYPRESS_ENV|CYPRESS_KONFIG_ENV)"

This will print any environment variables set to either of these values on the system.

If this returns nothing, open a new issue.

If this returns a value, then you will need to unset these environment variables since these are reserved environment variables in Cypress.

Instructions on unsetting an env var on Linux/MacOS

Instructions on unsetting an env var on Windows

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg/server This is due to an issue in the packages/server directory type: bug
Projects
None yet
Development

No branches or pull requests

1 participant