An error occurred while publishing plan XXXX-XXXX: Duplicate key 141361704
Asked by rwarden:

I am trying to create specs using java code to publish:

```
mvn -X -Ppublish-specs -Dbamboo.specs.log.level=TRACE
```

However, when trying to publish I am getting the following error:

```
build 26-Mar-2020 12:10:50 2020-03-26 12:10:50,045 TRACE [RestHelper] POST https://<bambo-server>/rest/api/latest/import/plan HTTP/1.1 - sending
build 26-Mar-2020 12:10:51 2020-03-26 12:10:51,971 TRACE [RestHelper] POST https://<bambo-server>/rest/api/latest/import/plan HTTP/1.1 - failed, status: 400, error: Duplicate key 141361704
build 26-Mar-2020 12:10:51 2020-03-26 12:10:51,974 TRACE [RestHelper] {"message":"Duplicate key 141361704","status-code":400}
build 26-Mar-2020 12:10:51 2020-03-26 12:10:51,977 INFO [BambooServer] An error occurred while publishing plan MOLECULETESTS-FDJAFKSJDF: Duplicate key 141361704
build 26-Mar-2020 12:10:51 2020-03-26 12:10:51,979 DEBUG [BambooServer] {"message":"Duplicate key 141361704","status-code":400}
```

This plan does not exist, e.g. if I try the following:  
https://\<bambo-server\>/exportSpecs/plan.action?buildKey=MOLECULETESTS-FDJAFKSJDF

Then it will return "Export to Bamboo Specs failed: null" as it does not exist.

How can I find out what key it thinks is duplicated?


Answers:
author: Marcin Gardias
body: Hi,

It would help narrow down the problem if you can find the full stack trace of this error in the bamboo server logs and post it here.

comments: author: rwarden
body: Here is the full stack:

```
build 26-Mar-2020 12:10:52 [ERROR] Failed to execute goal com.atlassian.bamboo:bamboo-specs-runner:6.5.0:run (default-cli) on project molecule-tests-bamboo-specs: Execution default-cli of goal com.atlassian.bamboo:bamboo-specs-runner:6.5.0:run failed: java.lang.reflect.InvocationTargetException: An error occurred while publishing plan MOLECULETESTS-FDJAFKSJDF: Duplicate key 141361704 -> [Help 1]
build 26-Mar-2020 12:10:52 org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.atlassian.bamboo:bamboo-specs-runner:6.5.0:run (default-cli) on project molecule-tests-bamboo-specs: Execution default-cli of goal com.atlassian.bamboo:bamboo-specs-runner:6.5.0:run failed: java.lang.reflect.InvocationTargetException
build 26-Mar-2020 12:10:52 at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213)
build 26-Mar-2020 12:10:52 at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154)
build 26-Mar-2020 12:10:52 at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146)
build 26-Mar-2020 12:10:52 at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
build 26-Mar-2020 12:10:52 at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
build 26-Mar-2020 12:10:52 at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
build 26-Mar-2020 12:10:52 at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
build 26-Mar-2020 12:10:52 at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:309)
build 26-Mar-2020 12:10:52 at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:194)
build 26-Mar-2020 12:10:52 at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:107)
build 26-Mar-2020 12:10:52 at org.apache.maven.cli.MavenCli.execute(MavenCli.java:993)
build 26-Mar-2020 12:10:52 at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:345)
build 26-Mar-2020 12:10:52 at org.apache.maven.cli.MavenCli.main(MavenCli.java:191)
build 26-Mar-2020 12:10:52 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
build 26-Mar-2020 12:10:52 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
build 26-Mar-2020 12:10:52 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
build 26-Mar-2020 12:10:52 at java.lang.reflect.Method.invoke(Method.java:498)
build 26-Mar-2020 12:10:52 at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
build 26-Mar-2020 12:10:52 at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
build 26-Mar-2020 12:10:52 at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
build 26-Mar-2020 12:10:52 at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
build 26-Mar-2020 12:10:52 Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-cli of goal com.atlassian.bamboo:bamboo-specs-runner:6.5.0:run failed: java.lang.reflect.InvocationTargetException
build 26-Mar-2020 12:10:52 at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:145)
build 26-Mar-2020 12:10:52 at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
build 26-Mar-2020 12:10:52 ... 20 more
build 26-Mar-2020 12:10:52 Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
build 26-Mar-2020 12:10:52 at com.atlassian.bamboo.specs.maven.sandbox.SpecsRunner.callMainMethod(SpecsRunner.java:100)
build 26-Mar-2020 12:10:52 at com.atlassian.bamboo.specs.maven.sandbox.SpecsRunner.runSpecsInternal(SpecsRunner.java:76)
build 26-Mar-2020 12:10:52 at com.atlassian.bamboo.specs.maven.sandbox.SpecsRunner.runSpecs(SpecsRunner.java:48)
build 26-Mar-2020 12:10:52 at com.atlassian.bamboo.specs.maven.RunBambooSpecsMojo.execute(RunBambooSpecsMojo.java:88)
build 26-Mar-2020 12:10:52 at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
build 26-Mar-2020 12:10:52 ... 21 more
build 26-Mar-2020 12:10:52 Caused by: java.lang.reflect.InvocationTargetException
build 26-Mar-2020 12:10:52 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
build 26-Mar-2020 12:10:52 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
build 26-Mar-2020 12:10:52 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
build 26-Mar-2020 12:10:52 at java.lang.reflect.Method.invoke(Method.java:498)
build 26-Mar-2020 12:10:52 at com.atlassian.bamboo.specs.maven.sandbox.SpecsRunner.callMainMethod(SpecsRunner.java:95)
build 26-Mar-2020 12:10:52 ... 25 more
build 26-Mar-2020 12:10:52 Caused by: com.atlassian.bamboo.specs.api.exceptions.BambooSpecsPublishingException: An error occurred while publishing plan MOLECULETESTS-FDJAFKSJDF: Duplicate key 141361704
build 26-Mar-2020 12:10:52 at com.atlassian.bamboo.specs.util.BambooServer.translateRestException(BambooServer.java:178)
build 26-Mar-2020 12:10:52 at com.atlassian.bamboo.specs.util.BambooServer.translateException(BambooServer.java:148)
build 26-Mar-2020 12:10:52 at com.atlassian.bamboo.specs.util.BambooServer.publish(BambooServer.java:101)
build 26-Mar-2020 12:10:52 at specs.main.lambda$main$0(main.java:75)
build 26-Mar-2020 12:10:52 at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1374)
build 26-Mar-2020 12:10:52 at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580)
build 26-Mar-2020 12:10:52 at specs.main.main(main.java:74)
build 26-Mar-2020 12:10:52 ... 30 more
build 26-Mar-2020 12:10:52 Caused by: com.atlassian.bamboo.specs.exceptions.BambooSpecsRestRequestException: Duplicate key 141361704
build 26-Mar-2020 12:10:52 at com.atlassian.bamboo.specs.util.RestHelper.lambda$sendRequest$2(RestHelper.java:89)
build 26-Mar-2020 12:10:52 at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:222)
build 26-Mar-2020 12:10:52 at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:164)
build 26-Mar-2020 12:10:52 at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:139)
build 26-Mar-2020 12:10:52 at com.atlassian.bamboo.specs.util.RestHelper.sendRequest(RestHelper.java:92)
build 26-Mar-2020 12:10:52 at com.atlassian.bamboo.specs.util.RestHelper.post(RestHelper.java:201)
build 26-Mar-2020 12:10:52 at com.atlassian.bamboo.specs.util.SendQueue$1.run(SendQueue.java:23)
build 26-Mar-2020 12:10:52 [ERROR] 
build 26-Mar-2020 12:10:52 [ERROR] 
build 26-Mar-2020 12:10:52 [ERROR] For more information about the errors and possible solutions, please read the following articles:
build 26-Mar-2020 12:10:52 [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
error 26-Mar-2020 12:10:52 Error occurred while running Task 'Run Maven Build(5)' of type com.atlassian.bamboo.plugins.bamboo-docker-plugin:task.docker.cli.
error 26-Mar-2020 12:10:52 com.atlassian.bamboo.task.TaskException: Failed to execute task
error 26-Mar-2020 12:10:52 at com.atlassian.bamboo.plugins.docker.service.RunService.execute(RunService.java:75)
error 26-Mar-2020 12:10:52 at com.atlassian.bamboo.plugins.docker.tasks.cli.DockerCliTask.execute(DockerCliTask.java:70)
error 26-Mar-2020 12:10:52 at com.atlassian.bamboo.task.TaskExecutorImpl.lambda$executeTasks$3(TaskExecutorImpl.java:285)
error 26-Mar-2020 12:10:52 at com.atlassian.bamboo.task.TaskExecutorImpl.executeTaskWithPrePostActions(TaskExecutorImpl.java:224)
error 26-Mar-2020 12:10:52 at com.atlassian.bamboo.task.TaskExecutorImpl.executeTasks(TaskExecutorImpl.java:285)
error 26-Mar-2020 12:10:52 at com.atlassian.bamboo.task.TaskExecutorImpl.execute(TaskExecutorImpl.java:112)
error 26-Mar-2020 12:10:52 at com.atlassian.bamboo.build.pipeline.tasks.ExecuteBuildTask.call(ExecuteBuildTask.java:71)
error 26-Mar-2020 12:10:52 at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent.executeBuildPhase(DefaultBuildAgent.java:203)
error 26-Mar-2020 12:10:52 at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent.build(DefaultBuildAgent.java:175)
error 26-Mar-2020 12:10:52 at com.atlassian.bamboo.v2.build.agent.BuildAgentControllerImpl.lambda$waitAndPerformBuild$0(BuildAgentControllerImpl.java:122)
error 26-Mar-2020 12:10:52 at com.atlassian.bamboo.variable.CustomVariableContextImpl.withVariableSubstitutor(CustomVariableContextImpl.java:185)
error 26-Mar-2020 12:10:52 at com.atlassian.bamboo.v2.build.agent.BuildAgentControllerImpl.waitAndPerformBuild(BuildAgentControllerImpl.java:117)
error 26-Mar-2020 12:10:52 at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent$1.run(DefaultBuildAgent.java:126)
error 26-Mar-2020 12:10:52 at com.atlassian.bamboo.utils.BambooRunnables$1.run(BambooRunnables.java:48)
error 26-Mar-2020 12:10:52 at com.atlassian.bamboo.security.ImpersonationHelper.runWith(ImpersonationHelper.java:26)
error 26-Mar-2020 12:10:52 at com.atlassian.bamboo.security.ImpersonationHelper.runWithSystemAuthority(ImpersonationHelper.java:17)
error 26-Mar-2020 12:10:52 at com.atlassian.bamboo.security.ImpersonationHelper$1.run(ImpersonationHelper.java:41)
error 26-Mar-2020 12:10:52 at java.lang.Thread.run(Thread.java:748)
error 26-Mar-2020 12:10:52 Caused by: com.atlassian.bamboo.docker.DockerException: Error running Docker run command
error 26-Mar-2020 12:10:52 at com.atlassian.bamboo.docker.DockerContainerServiceImpl.run(DockerContainerServiceImpl.java:118)
error 26-Mar-2020 12:10:52 at sun.reflect.GeneratedMethodAccessor127.invoke(Unknown Source)
error 26-Mar-2020 12:10:52 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
error 26-Mar-2020 12:10:52 at java.lang.reflect.Method.invoke(Method.java:498)
error 26-Mar-2020 12:10:52 at com.atlassian.plugin.util.ContextClassLoaderSettingInvocationHandler.invoke(ContextClassLoaderSettingInvocationHandler.java:26)
error 26-Mar-2020 12:10:52 at com.sun.proxy.$Proxy94.run(Unknown Source)
error 26-Mar-2020 12:10:52 at sun.reflect.GeneratedMethodAccessor127.invoke(Unknown Source)
error 26-Mar-2020 12:10:52 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
error 26-Mar-2020 12:10:52 at java.lang.reflect.Method.invoke(Method.java:498)
error 26-Mar-2020 12:10:52 at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:302)
error 26-Mar-2020 12:10:52 at org.eclipse.gemini.blueprint.service.importer.support.internal.aop.ServiceInvoker.doInvoke(ServiceInvoker.java:56)
error 26-Mar-2020 12:10:52 at org.eclipse.gemini.blueprint.service.importer.support.internal.aop.ServiceInvoker.invoke(ServiceInvoker.java:60)
error 26-Mar-2020 12:10:52 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
error 26-Mar-2020 12:10:52 at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:133)
error 26-Mar-2020 12:10:52 at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:121)
error 26-Mar-2020 12:10:52 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
error 26-Mar-2020 12:10:52 at org.eclipse.gemini.blueprint.service.util.internal.aop.ServiceTCCLInterceptor.invokeUnprivileged(ServiceTCCLInterceptor.java:70)
error 26-Mar-2020 12:10:52 at org.eclipse.gemini.blueprint.service.util.internal.aop.ServiceTCCLInterceptor.invoke(ServiceTCCLInterceptor.java:53)
error 26-Mar-2020 12:10:52 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
error 26-Mar-2020 12:10:52 at org.eclipse.gemini.blueprint.service.importer.support.LocalBundleContextAdvice.invoke(LocalBundleContextAdvice.java:57)
error 26-Mar-2020 12:10:52 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
error 26-Mar-2020 12:10:52 at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:133)
error 26-Mar-2020 12:10:52 at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:121)
error 26-Mar-2020 12:10:52 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
error 26-Mar-2020 12:10:52 at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
error 26-Mar-2020 12:10:52 at com.sun.proxy.$Proxy152.run(Unknown Source)
error 26-Mar-2020 12:10:52 at com.atlassian.bamboo.plugins.docker.client.DockerCmd.run(DockerCmd.java:51)
error 26-Mar-2020 12:10:52 at com.atlassian.bamboo.plugins.docker.service.RunService.execute(RunService.java:64)
error 26-Mar-2020 12:10:52 ... 17 more
```


author: rwarden
body: Any pointers at all? Or at least how I can further debug what the issue might be?

Thanks


author: Marcin Gardias
body: Hi, that looks like a build log. What I meant is bamboo _server_ log, to be found in \<bamboo_home\>/logs


author: rwarden
body: Stack from the bamboo server log after turning root leven to ALL:  

```
2020-04-03 10:31:20,879 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] [ERROR] Failed to execute goal com.atlassian.bamboo:bamboo-specs-runner:6.5.0:run (default-cli) on project molecule-tests-bamboo-specs: Execution default-cli of goal com.atlassian.bamboo:bamboo-specs-runner:6.5.0:run failed: java.lang.reflect.InvocationTargetException: An error occurred while publishing plan MOLECULETESTS-MOLEJAVA2: Duplicate key 141361801 -> [Help 1]
2020-04-03 10:31:20,879 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.atlassian.bamboo:bamboo-specs-runner:6.5.0:run (default-cli) on project molecule-tests-bamboo-specs: Execution default-cli of goal com.atlassian.bamboo:bamboo-specs-runner:6.5.0:run failed: java.lang.reflect.InvocationTargetException
2020-04-03 10:31:20,879 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213)
2020-04-03 10:31:20,879 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154)
2020-04-03 10:31:20,879 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146)
2020-04-03 10:31:20,879 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
2020-04-03 10:31:20,879 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
2020-04-03 10:31:20,880 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
2020-04-03 10:31:20,880 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
2020-04-03 10:31:20,880 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:309)
2020-04-03 10:31:20,880 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:194)
2020-04-03 10:31:20,880 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:107)
2020-04-03 10:31:20,880 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] at org.apache.maven.cli.MavenCli.execute(MavenCli.java:993)
2020-04-03 10:31:20,880 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:345)
2020-04-03 10:31:20,880 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] at org.apache.maven.cli.MavenCli.main(MavenCli.java:191)
2020-04-03 10:31:20,880 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2020-04-03 10:31:20,880 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
2020-04-03 10:31:20,880 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
2020-04-03 10:31:20,880 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] at java.lang.reflect.Method.invoke(Method.java:498)
2020-04-03 10:31:20,880 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
2020-04-03 10:31:20,880 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
2020-04-03 10:31:20,881 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
2020-04-03 10:31:20,881 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
2020-04-03 10:31:20,881 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-cli of goal com.atlassian.bamboo:bamboo-specs-runner:6.5.0:run failed: java.lang.reflect.InvocationTargetException
2020-04-03 10:31:20,881 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:145)
2020-04-03 10:31:20,881 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
2020-04-03 10:31:20,881 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] ... 20 more
2020-04-03 10:31:20,881 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
2020-04-03 10:31:20,881 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] at com.atlassian.bamboo.specs.maven.sandbox.SpecsRunner.callMainMethod(SpecsRunner.java:100)
2020-04-03 10:31:20,881 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] at com.atlassian.bamboo.specs.maven.sandbox.SpecsRunner.runSpecsInternal(SpecsRunner.java:76)
2020-04-03 10:31:20,881 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] at com.atlassian.bamboo.specs.maven.sandbox.SpecsRunner.runSpecs(SpecsRunner.java:48)
2020-04-03 10:31:20,881 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] at com.atlassian.bamboo.specs.maven.RunBambooSpecsMojo.execute(RunBambooSpecsMojo.java:88)
2020-04-03 10:31:20,881 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
2020-04-03 10:31:20,881 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] ... 21 more
2020-04-03 10:31:20,882 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] Caused by: java.lang.reflect.InvocationTargetException
2020-04-03 10:31:20,882 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2020-04-03 10:31:20,882 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
2020-04-03 10:31:20,882 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
2020-04-03 10:31:20,882 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] at java.lang.reflect.Method.invoke(Method.java:498)
2020-04-03 10:31:20,882 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] at com.atlassian.bamboo.specs.maven.sandbox.SpecsRunner.callMainMethod(SpecsRunner.java:95)
2020-04-03 10:31:20,882 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] ... 25 more
2020-04-03 10:31:20,882 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] Caused by: com.atlassian.bamboo.specs.api.exceptions.BambooSpecsPublishingException: An error occurred while publishing plan MOLECULETESTS-MOLEJAVA2: Duplicate key 141361801
2020-04-03 10:31:20,882 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] at com.atlassian.bamboo.specs.util.BambooServer.translateRestException(BambooServer.java:178)
2020-04-03 10:31:20,882 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] at com.atlassian.bamboo.specs.util.BambooServer.translateException(BambooServer.java:148)
2020-04-03 10:31:20,882 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] at com.atlassian.bamboo.specs.util.BambooServer.publish(BambooServer.java:101)
2020-04-03 10:31:20,882 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] at specs.main.lambda$main$0(main.java:75)
2020-04-03 10:31:20,882 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1374)
2020-04-03 10:31:20,883 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580)
2020-04-03 10:31:20,883 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] at specs.main.main(main.java:74)
2020-04-03 10:31:20,883 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] ... 30 more
2020-04-03 10:31:20,883 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] Caused by: com.atlassian.bamboo.specs.exceptions.BambooSpecsRestRequestException: Duplicate key 141361801
2020-04-03 10:31:20,883 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] at com.atlassian.bamboo.specs.util.RestHelper.lambda$sendRequest$2(RestHelper.java:89)
2020-04-03 10:31:20,883 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:222)
2020-04-03 10:31:20,883 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:164)
2020-04-03 10:31:20,883 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:139)
2020-04-03 10:31:20,883 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] at com.atlassian.bamboo.specs.util.RestHelper.sendRequest(RestHelper.java:92)
2020-04-03 10:31:20,883 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] at com.atlassian.bamboo.specs.util.RestHelper.post(RestHelper.java:201)
2020-04-03 10:31:20,883 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] at com.atlassian.bamboo.specs.util.SendQueue$1.run(SendQueue.java:23)
2020-04-03 10:31:20,883 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] [ERROR] 
2020-04-03 10:31:20,883 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] [ERROR] 
2020-04-03 10:31:20,884 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] [ERROR] For more information about the errors and possible solutions, please read the following articles:
2020-04-03 10:31:20,884 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
```


author: Marcin Gardias
body: You just posted the same information again from different source, this is trace from the service that intercepts build logs and stores them on the server.

Please revert the logging levels to what they were. Retry specs publishing request. There should be an

```
IllegalStateException
```

with message

```
Duplicate key 141361801
```

logged on the server, coming from the thread _that handles the REST request_. I need that one.


author: rwarden
body: Sorry, but there is no other stack that is being logged really. I cannot see any entry of

```
IllegalStateException
```

The thread handling the REST request does not throw any errors, it gets to the part where it tries to insert into the database then throws the duplicate key error as below:

```
2020-04-03 10:31:19,282 DEBUG [http-nio-8085-exec-351] [PlanHibernateDao] Saving: <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<configuration xml:space="preserve">
<isMergedConfiguration>false</isMergedConfiguration>
<cleanWorkingDirectory>false</cleanWorkingDirectory>
<repositoryDefiningWorkingDirectory>-1</repositoryDefiningWorkingDirectory>
<buildTasks>
<taskDefinition>
<id>1</id>
<userDescription>Checkout Default Repository</userDescription>
<isEnabled>true</isEnabled>
<pluginKey>com.atlassian.bamboo.plugins.vcs:task.vcs.checkout</pluginKey>
<finalising>false</finalising>
<rootDirectoryType>INHERITED</rootDirectoryType>
<repositoryDefiningWorkingDir>-1</repositoryDefiningWorkingDir>
<oid>6945535787823898625</oid>
<config>
<item>
<key>cleanCheckout</key>
<value>false</value>
</item>
<item>
<key>checkoutDir_1</key>
<value>ansible-molecule-tests</value>
</item>
<item>
<key>selectedRepository_0</key>
<value>defaultRepository</value>
</item>
<item>
<key>checkoutDir_0</key>
<value/>
</item>
<item>
<key>selectedRepository_1</key>
<value>141361801</value>
</item>
</config>
</taskDefinition>
<taskDefinition>
<id>2</id>
<userDescription>Activate virtualenv and install requirements</userDescription>
<isEnabled>true</isEnabled>
<pluginKey>com.atlassian.bamboo.plugins.scripttask:task.builder.script</pluginKey>
<finalising>false</finalising>
<rootDirectoryType>INHERITED</rootDirectoryType>
<repositoryDefiningWorkingDir>-1</repositoryDefiningWorkingDir>
<oid>6945535787823898626</oid>
<config>
<item>
<key>interpreter</key>
<value>RUN_AS_EXECUTABLE</value>
</item>
<item>
<key>scriptLocation</key>
<value>INLINE</value>
</item>
<item>
<key>scriptBody</key>
<value>#!/bin/bash
source .venv/bin/activate || virtualenv -p $( which python3 ) .venv &amp;&amp; source .venv/bin/activate || exit 1
pip install -r requirements.txt || exit 1</value>
</item>
</config>
</taskDefinition>
<taskDefinition>
<id>3</id>
<userDescription>Run molecule test</userDescription>
<isEnabled>true</isEnabled>
<pluginKey>com.atlassian.bamboo.plugins.scripttask:task.builder.script</pluginKey>
<finalising>false</finalising>
<rootDirectoryType>INHERITED</rootDirectoryType>
<repositoryDefiningWorkingDir>-1</repositoryDefiningWorkingDir>
<oid>6945535787823898627</oid>
<config>
<item>
<key>interpreter</key>
<value>RUN_AS_EXECUTABLE</value>
</item>
<item>
<key>scriptLocation</key>
<value>INLINE</value>
</item>
<item>
<key>scriptBody</key>
<value>#!/bin/bash
source .venv/bin/activate
export ANSIBLE_VAULT_PASSWORD_FILE=$(echo $(pwd)/.vaultpass)
cd roles/install-java
molecule --debug test --all --destroy=always</value>
</item>
</config>
</taskDefinition>
</buildTasks>
<triggers>
<defined>true</defined>
</triggers>
<branches>
<workflow>manual</workflow>
<branchRemovalCleanUpEnabled>false</branchRemovalCleanUpEnabled>
<inactiveBranchCleanupEnabled>false</inactiveBranchCleanupEnabled>
<matchingPattern>.*</matchingPattern>
<removalCleanupPeriodInDays>7</removalCleanupPeriodInDays>
<inactivityInDays>30</inactivityInDays>
<defaultNotificationStrategy>notifyCommitters</defaultNotificationStrategy>
<issueLinking>true</issueLinking>
<branchTriggering>inherited</branchTriggering>
</branches>
<branches>
<defaultBranchIntegration>
<enabled>false</enabled>
</defaultBranchIntegration>
</branches>
<branchIntegration>
<enabled>false</enabled>
</branchIntegration>
<branchConfiguration>
<cleanup>
<disabled>false</disabled>
</cleanup>
<notificationStrategy>notifyCommitters</notificationStrategy>
<workflow>manual</workflow>
</branchConfiguration>
<docker>
<pipeline>
<enabled>false</enabled>
</pipeline>
</docker>
<bambooDelimiterParsingDisabled>true</bambooDelimiterParsingDisabled>
</configuration>

2020-04-03 10:31:19,309 DEBUG [http-nio-8085-exec-351] [AccessLogFilter] END: 400 bamboo POST https://<bamboo-server>/rest/api/latest/import/plan 1374507kb-39529kb 700ms
```

Duplicate key error on insert:

```
2020-04-03 10:31:19,870 DEBUG [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [BambooAgentMessageListener] received message, delivery duration: 3ms, message size: 2036
2020-04-03 10:31:19,870 DEBUG [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [LogMessageStream] Delivering 9 log messages for BAMBSPECS-MOLECU-RUN-18, total message size: 897
2020-04-03 10:31:19,870 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] 2020-04-03 09:31:19,708 TRACE [RestHelper] POST https://<bamboo-server>/rest/api/latest/import/plan HTTP/1.1 - failed, status: 400, error: Duplicate key 141361801
2020-04-03 10:31:19,870 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] 2020-04-03 09:31:19,711 TRACE [RestHelper] {"message":"Duplicate key 141361801","status-code":400}
2020-04-03 10:31:19,871 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] 2020-04-03 09:31:19,714 INFO [BambooServer] An error occurred while publishing plan MOLECULETESTS-MOLEJAVA2: Duplicate key 141361801
2020-04-03 10:31:19,871 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] 2020-04-03 09:31:19,715 DEBUG [BambooServer] {"message":"Duplicate key 141361801","status-code":400}
2020-04-03 10:31:19,871 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] [INFO] ------------------------------------------------------------------------
2020-04-03 10:31:19,871 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] [INFO] BUILD FAILURE
2020-04-03 10:31:19,871 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] [INFO] ------------------------------------------------------------------------
2020-04-03 10:31:19,871 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] [INFO] Total time: 20.206 s
2020-04-03 10:31:19,871 TRACE [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [AbstractBuildLogger] [INFO] Finished at: 2020-04-03T09:31:19Z
2020-04-03 10:31:19,871 DEBUG [8-BuildTailMessageProcessingThread:pool-14-thread-3409] [BambooAgentMessageListener] Processing of message took 1ms, the message is of type LogMessageStream, content: com.atlassian.bamboo.v2.build.agent.messages.LogMessageStream@473fd79f
```

Note: Every time I try to re-publish the same specs plan it will throw the same error but about a different duplicate key ID, so it is as if it is trying to insert the same key twice within the same request it seems.


author: Marcin Gardias
body: The id refers to the repository definition. Which version of Bamboo is it?


author: rwarden
body: Version 6.5.0


author: Marcin Gardias
body: That version is quite old and will reach EOL 24th of April. So here's my suggestion: please upgrade, chances are this problem is fixed in more recent versions of Bamboo. If problem still exists after that, contact our support.


author: Marcin Gardias
body: One more idea: do you use 'linked repository' or do you define repository locally in the plan? If it's the latter, perhaps you should try the first approach.


author: rwarden
body: Thanks for your help. After you said the key referred to repository definition I could spot the issue. I was using a linked repository, but also trying to checkout the same repository.