eirslett / frontend-maven-plugin

"Maven-node-grunt-gulp-npm-node-plugin to end all maven-node-grunt-gulp-npm-plugins." A Maven plugin that downloads/installs Node and NPM locally, runs NPM install, Grunt, Gulp and/or Karma.
Apache License 2.0
4.26k stars 870 forks source link

Problem parsing cookie header causing yarn install to fail #607

Open MattMoranJava opened 7 years ago

MattMoranJava commented 7 years ago

My frontend build is failing with the following log:

[INFO] --- frontend-maven-plugin:1.2:install-node-and-yarn (install node and yarn) @ cdx-frontend --- [INFO] Installing node version v6.2.2 [INFO] Unpacking /root/.m2/repository/com/github/eirslett/node/6.2.2/node-6.2.2-linux-x64.tar.gz into /usr/local/build/cdxwww/react-frontend/target/node/tmp [INFO] Copying node binary from /usr/local/build/cdxwww/react-frontend/target/node/tmp/node-v6.2.2-linux-x64/bin/node to /usr/local/build/cdxwww/react-frontend/target/node/node [INFO] Installed node locally. [INFO] Installing Yarn version v0.16.1 [INFO] Downloading https://github.com/yarnpkg/yarn/releases/download/v0.16.1/yarn-v0.16.1.tar.gz to /root/.m2/repository/com/github/eirslett/yarn/0.16.1/yarn-0.16.1./yarn-v0.16.1.tar.gz [INFO] No proxies configured [INFO] No proxy was configured, downloading directly May 19, 2017 9:18:33 AM org.apache.http.client.protocol.ResponseProcessCookies processCookies WARNING: Invalid cookie header: "Set-Cookie: logged_in=no; domain=.github.com; path=/; expires=Tue, 19 May 2037 09:18:36 -0000; secure; HttpOnly". Invalid 'expires' attribute: Tue, 19 May 2037 09:18:36 -0000 [INFO] ------------------------------------------------------------------------ [INFO] Reactor Summary: [INFO] [INFO] cdx-parent ......................................... SUCCESS [ 2.076 s] [INFO] cdx-frontend ....................................... FAILURE [ 40.378 s] [INFO] cdxwww Webapp ...................................... SKIPPED [INFO] Project Aggregator ................................. SKIPPED [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 43.055 s [INFO] Finished at: 2017-05-19T09:18:36Z [INFO] Final Memory: 15M/172M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.2:install-node-and-yarn (install node and yarn) on project cdx-frontend: Could not download Yarn: Could not download https://github.com/yarnpkg/yarn/releases/download/v0.16.1/yarn-v0.16.1.tar.gz: /root/.m2/repository/com/github/eirslett/yarn/0.16.1/yarn-0.16.1./yarn-v0.16.1.tar.gz (No such file or directory) -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException [ERROR] [ERROR] After correcting the problems, you can resume the build with the command [ERROR] mvn -rf :cdx-frontend Do you want to request a feature or report a bug? Report a bug. I believe it may be possible to overcome this by setting a System property to be able to parse the latest format cookie headers. What is the current behavior? Failing due to being unable to parse the cookie header expiry coming from yarn's github. If the current behavior is a bug, please provide the steps to reproduce. Run install-node-and-yarn in maven. What is the expected behavior? Yarn should be installed Please mention your frontend-maven-plugin and operating system version. frontend-maven-plugin v1.2, OS is complex: Debian Jessie running as a Docker container inside Windows 10

mriehema commented 7 years ago

Please update to latest frontend-maven-plugin. Does the error still occur?

MattMoranJava commented 7 years ago

Yep, still happens with 1.4. I think the problem is that the spec for cookie headers specifies that the Expires attribute should be capitalised, and the one returned by github for yarn is "expires", all lower case. We either need them to fix their side or we need to make our cookie parsing more resilient. ISTR there's a way to do this in Java by setting a system property, but I'm not 100% sure of exactly what to do, or I'd fix it myself :-)

detro commented 7 years ago

This is happening to me as well:

Jun 13, 2017 1:20:37 PM org.apache.http.client.protocol.ResponseProcessCookies processCookies
WARNING: Invalid cookie header: "Set-Cookie: logged_in=no; domain=.github.com; path=/; expires=Sat, 13 Jun 2037 13:20:37 -0000; secure; HttpOnly". Invalid 'expires' attribute: Sat, 13 Jun 2037 13:20:37 -0000
[ERROR] error Bad hash. Expected "f8990e71c9cd180a842b07e09e0801fe84e83878" but got "71046f074813d02439ba0af58816f39b37c8aa9f" 
[ERROR] error Command failed with exit code 1.
[ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.4:yarn (yarn install) on project synthetics-web: Failed to run task: 'yarn run install-offline' failed. org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1) -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

This is how I have the plugin configured:

<plugin>
          <groupId>com.github.eirslett</groupId>
          <artifactId>frontend-maven-plugin</artifactId>
          <version>1.4</version>
        </plugin>
...
<groupId>com.github.eirslett</groupId>
        <artifactId>frontend-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>install node and yarn</id>
            <goals>
              <goal>install-node-and-yarn</goal>
            </goals>
            <phase>generate-resources</phase>
          </execution>
          <execution>
            <id>yarn install</id>
            <goals>
              <goal>yarn</goal>
            </goals>
            <phase>generate-resources</phase>
            <configuration>
              <arguments>run install-offline</arguments>
            </configuration>
          </execution>
          <execution>
            <id>webpack build</id>
            <goals>
              <goal>webpack</goal>
            </goals>
            <phase>generate-resources</phase>
            <configuration>
              <arguments>-prod</arguments>
            </configuration>
          </execution>
        </executions>
        <configuration>
          <nodeVersion>v4.8.3</nodeVersion>
          <yarnVersion>v0.24.6</yarnVersion>
          <failOnError>true</failOnError>
        </configuration>
      </plugin>

How can we circumvent this issue?

auxiliaire commented 6 years ago

I guess I'm having the same issue with 1.6:

INFO  [2018-02-22 22:18:31,691] [Hotswap] Downloading https://github.com/yarnpkg/yarn/releases/download/npm-v1.3.2.tgz to C:\Users\vikto\.m2\repository\com\github\eirslett\npm\1.3.2\npm-1.3.2.tar.gz
INFO  [2018-02-22 22:18:31,693] [Hotswap] No proxies configured
INFO  [2018-02-22 22:18:31,693] [Hotswap] No proxy was configured, downloading directly
febr. 22, 2018 10:18:32 DU org.apache.http.client.protocol.ResponseProcessCookies processCookies
INFO  [2018-02-22 22:18:32,891] [Hotswap] Stopped
WARNING: Invalid cookie header: "Set-Cookie: logged_in=no; domain=.github.com; path=/; expires=Mon, 22 Feb 2038 21:18:32 -0000; secure; HttpOnly". Invalid 'expires' attribute: Mon, 22 Feb 2038 21:18:32 -0000
ERROR [2018-02-22 22:18:32,893] [Hotswap] An error occurred while starting the application:
com.github.eirslett.maven.plugins.frontend.lib.InstallationException: Could not download npm
    at com.github.eirslett.maven.plugins.frontend.lib.NPMInstaller.installNpm(NPMInstaller.java:167)

I'm running in IntelliJ on Windows 10.

fdlk commented 6 years ago

I think the warning is unrelated to the failure, since I came here looking for the warning but the build succeeds on my machine.

wilx commented 4 years ago

I am noticing this too, with 1.9.1:

00:01:09.066 WARNING: Invalid cookie header: "Set-Cookie: logged_in=no; Path=/; Domain=github.com; Expires=Sat, 29 May 2021 13:03:41 GMT; HttpOnly; Secure; SameSite=Lax". Invalid 'expires' attribute: Sat, 29 May 2021 13:03:41 GMT
JanBdot commented 4 years ago

I experienced the same issue and the reason was that one repository from my package.json was set to private. That's why the plugin wanted to set a github cookie in the first place. It showed in the Server Log, but not on the Console, so it took me forever to find the error.