github / maven-plugins

Official GitHub Maven Plugins
MIT License
584 stars 198 forks source link

site goal fails with "Invalid request. nil is not a string. (422)" #85

Open veithen opened 9 years ago

veithen commented 9 years ago

I tried to set up site-maven-plugin version 0.11 for one of my projects and got the following failure:

[ERROR] Failed to execute goal com.github.github:site-maven-plugin:0.11:site (default) on project alta-maven-plugin: Error creating commit: Invalid request.
[ERROR] 
[ERROR] nil is not a string.
[ERROR] nil is not a string. (422)
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.github.github:site-maven-plugin:0.11:site (default) on project alta-maven-plugin: Error creating commit: Invalid request.

nil is not a string.
nil is not a string. (422)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:108)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:76)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:116)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:361)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:213)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:157)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: Error creating commit: Invalid request.

nil is not a string.
nil is not a string. (422)
    at com.github.maven.plugins.site.SiteMojo.execute(SiteMojo.java:461)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:133)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    ... 19 more
Caused by: org.eclipse.egit.github.core.client.RequestException: Invalid request.

nil is not a string.
nil is not a string. (422)
    at org.eclipse.egit.github.core.client.GitHubClient.createException(GitHubClient.java:552)
    at org.eclipse.egit.github.core.client.GitHubClient.sendJson(GitHubClient.java:643)
    at org.eclipse.egit.github.core.client.GitHubClient.post(GitHubClient.java:757)
    at org.eclipse.egit.github.core.service.DataService.createCommit(DataService.java:397)
    at com.github.maven.plugins.site.SiteMojo.execute(SiteMojo.java:454)
    ... 21 more

After debugging, it turned out that this is because I didn't fill out my real name in my user profile. Probably the following piece of code in SiteMojo should be changed to check that user.getName() is not null, and generate a more meaningful error message if that's not the case:

UserService userService = new UserService(service.getClient());
User user = userService.getUser();

CommitUser author = new CommitUser();
author.setName(user.getName());
author.setEmail(userService.getEmails().get(0));
author.setDate(new GregorianCalendar().getTime());

commit.setAuthor(author);
commit.setCommitter(author);
vojtechhabarta commented 9 years ago

I had the same problem. Thanks @veithen for your workaround with name in the profile.

jan-molak commented 8 years ago

+1 I face the same issue

balajeetm commented 7 years ago

+1 facing the same issue. I had even set the user.name at the global level but it still failed. Hope you are talking about the git config user.name

Didn't work for me. Can you guys tell me what was the resolution

jan-molak commented 7 years ago

@balajeetm - I set the username in the pom, line 443

balajeetm commented 7 years ago

@jan-molak Thanks. I also set the user name in my github profile. It works now

vrolijken commented 7 years ago

As I'd like multiple people to be able to commit, I have my user name in my settings.xml as described in https://github.com/github/maven-plugins#settingsxml Looks like it won't work without the project.scm.* properties?

tanujwagh commented 7 years ago

Users make sure you filled your real name in profile on github.com, This will resolve the above error.