Bamboo Specs 6.1 throwing 'object references an unsaved transient instance' when creating new plan
Asked by Ryan Schaaf:

Since upgrading to Bamboo 6.1, we are no longer able to create new plans in existing projects through Bamboo-Specs API. This feature worked on Bamboo 6.0.

To reproduce, all we have to do is attempt to create a brand new build plan in an existing project. When executed, we get the following:

```


2017-07-28 11:49:36,631 INFO [BambooServer] Publishing plan ENOT-BLDRC
2017-07-28 11:49:37,648 INFO [BambooServer] An error occurred while publishing plan ENOT-BLDRC: object references an unsaved transient instance - save the transient instance beforeQuery flushing: com.atlassian.bamboo.plan.AbstractPlan; nested exception is org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance beforeQuery flushing: com.atlassian.bamboo.plan.AbstractPlan
Exception in thread "main" com.atlassian.bamboo.specs.api.exceptions.BambooSpecsPublishingException: An error occurred while publishing plan ENOT-BLDRC: object references an unsaved transient instance - save the transient instance beforeQuery flushing: com.atlassian.bamboo.plan.AbstractPlan; nested exception is org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance beforeQuery flushing: com.atlassian.bamboo.plan.AbstractPlan
2017-07-28 11:49:37,650 DEBUG [BambooServer] {"message":"object references an unsaved transient instance - save the transient instance beforeQuery flushing: com.atlassian.bamboo.plan.AbstractPlan; nested exception is org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance beforeQuery flushing: com.atlassian.bamboo.plan.AbstractPlan","status-code":500}
at com.atlassian.bamboo.specs.util.BambooServer.translateRestException(BambooServer.java:166)
at com.atlassian.bamboo.specs.util.BambooServer.translateException(BambooServer.java:136)
at com.atlassian.bamboo.specs.util.BambooServer.publish(BambooServer.java:93)
at com.mediant.bamboo.project.MediantProjectConfiguration.publish(MediantProjectConfiguration.java:23)
at com.mediant.bamboo.PlanSpec.main(PlanSpec.java:96)
Caused by: com.atlassian.bamboo.specs.exceptions.BambooSpecsRestRequestException: object references an unsaved transient instance - save the transient instance beforeQuery flushing: com.atlassian.bamboo.plan.AbstractPlan; nested exception is org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance beforeQuery flushing: com.atlassian.bamboo.plan.AbstractPlan
at com.atlassian.bamboo.specs.util.RestHelper.lambda$sendRequest$2(RestHelper.java:89)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:222)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:164)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:139)
at com.atlassian.bamboo.specs.util.RestHelper.sendRequest(RestHelper.java:92)
at com.atlassian.bamboo.specs.util.RestHelper.post(RestHelper.java:201)
at com.atlassian.bamboo.specs.util.SendQueue$1.run(SendQueue.java:23)
```

EDIT : Here is the log from the bamboo server that we are attempting to publish to

```
2017-07-28 12:52:09,097 WARN [ajp-nio-8009-exec-1] [BambooRuntimeExceptionMapper] Unexpected error from REST call

org.springframework.dao.InvalidDataAccessApiUsageException: object references an unsaved transient instance - save the transient instance beforeQuery flushing: com.atlassian.bamboo.plan.AbstractPlan; nested exception is org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance beforeQuery flushing: com.atlassian.bamboo.plan.AbstractPlan

        at org.springframework.orm.hibernate5.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:268)

        at org.springframework.orm.hibernate5.HibernateTemplate.doExecute(HibernateTemplate.java:362)

        at org.springframework.orm.hibernate5.HibernateTemplate.execute(HibernateTemplate.java:313)

        at com.atlassian.bamboo.repository.PlanRepositoryLinkHibernateDao.getPlanRepositoryLinks(PlanRepositoryLinkHibernateDao.java:32)

        at com.atlassian.bamboo.repository.RepositoryDefinitionManagerImpl.getPlanRepositoryDefinitions(RepositoryDefinitionManagerImpl.java:82)
```

However, if I go into bamboo and manually create the build plan and then re-run the bamboo-specs script, it completes successfully.


Answers:
author: Piotr Swiecicki
body: Seems like a potential bug, but I'm struggling to reproduce locally. Would you mind sharing your Bamboo Specs project with us so we can reproduce? Alternatively consider contacting our Support [https://support.atlassian.com/contact/#/ to](https://support.atlassian.com/contact/#/?to) avoid sharing your Bamboo Specs code publically.


Tags: spec