Rule labels can break export import

Description

If you set a label id on a rule, that doesn't exist in the target instance, the import fails with an unknown error in the UI and this stacktrace:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 INFO] [talledLocalContainer] 2018-03-23 11:12:57,058 http-bio-2990-exec-11 ERROR admin 672x6494x1 1vwdhmu 0:0:0:0:0:0:0:1 /rest/cb-automation/latest/project/GLOBAL/rule/import [c.a.p.r.c.error.jersey.ThrowableExceptionMapper] Uncaught exception thrown by REST service: Caught PSQLException for insert into "public"."AO_589059_RULE_TO_LABEL" ("RULE_ID", "LABEL_ID") [INFO] [talledLocalContainer] values (?, ?) [INFO] [talledLocalContainer] com.querydsl.core.QueryException: Caught PSQLException for insert into "public"."AO_589059_RULE_TO_LABEL" ("RULE_ID", "LABEL_ID") [INFO] [talledLocalContainer] values (?, ?) [INFO] [talledLocalContainer] at com.querydsl.sql.DefaultSQLExceptionTranslator.translate(DefaultSQLExceptionTranslator.java:50) [INFO] [talledLocalContainer] at com.querydsl.sql.Configuration.translate(Configuration.java:459) [INFO] [talledLocalContainer] at com.querydsl.sql.dml.SQLInsertClause.execute(SQLInsertClause.java:445) [INFO] [talledLocalContainer] at com.codebarrel.jira.plugin.automation.store.JiraAutomationConfigStore.lambda$insertLabels$14(JiraAutomationConfigStore.java:363) [INFO] [talledLocalContainer] at java.util.ArrayList.forEach(ArrayList.java:1249) [INFO] [talledLocalContainer] at com.codebarrel.jira.plugin.automation.store.JiraAutomationConfigStore.insertLabels(JiraAutomationConfigStore.java:361) [INFO] [talledLocalContainer] at com.codebarrel.jira.plugin.automation.store.JiraAutomationConfigStore.lambda$createRuleFromConfig$7(JiraAutomationConfigStore.java:194) [INFO] [talledLocalContainer] at com.codebarrel.data.api.jira.JiraDbConnectionManager.lambda$execute$0(JiraDbConnectionManager.java:34) [INFO] [talledLocalContainer] at com.atlassian.jira.database.DatabaseAccessorImpl.executeQuery(DatabaseAccessorImpl.java:68) [INFO] [talledLocalContainer] ... 2 filtered [INFO] [talledLocalContainer] at java.lang.reflect.Method.invoke(Method.java:498) [INFO] [talledLocalContainer] at com.atlassian.plugin.util.ContextClassLoaderSettingInvocationHandler.invoke(ContextClassLoaderSettingInvocationHandler.java:26) [INFO] [talledLocalContainer] at com.sun.proxy.$Proxy203.executeQuery(Unknown Source) [INFO] [talledLocalContainer] ... 2 filtered [INFO] [talledLocalContainer] at java.lang.reflect.Method.invoke(Method.java:498) [INFO] [talledLocalContainer] at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:302) [INFO] [talledLocalContainer] at org.eclipse.gemini.blueprint.service.importer.support.internal.aop.ServiceInvoker.doInvoke(ServiceInvoker.java:56) [INFO] [talledLocalContainer] at org.eclipse.gemini.blueprint.service.importer.support.internal.aop.ServiceInvoker.invoke(ServiceInvoker.java:60) [INFO] [talledLocalContainer] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) [INFO] [talledLocalContainer] at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:133) [INFO] [talledLocalContainer] at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:121) [INFO] [talledLocalContainer] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) [INFO] [talledLocalContainer] at org.eclipse.gemini.blueprint.service.util.internal.aop.ServiceTCCLInterceptor.invokeUnprivileged(ServiceTCCLInterceptor.java:70) [INFO] [talledLocalContainer] at org.eclipse.gemini.blueprint.service.util.internal.aop.ServiceTCCLInterceptor.invoke(ServiceTCCLInterceptor.java:53) [INFO] [talledLocalContainer] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) [INFO] [talledLocalContainer] at org.eclipse.gemini.blueprint.service.importer.support.LocalBundleContextAdvice.invoke(LocalBundleContextAdvice.java:57) [INFO] [talledLocalContainer] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) [INFO] [talledLocalContainer] at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:133) [INFO] [talledLocalContainer] at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:121) [INFO] [talledLocalContainer] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) [INFO] [talledLocalContainer] at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:208) [INFO] [talledLocalContainer] at com.sun.proxy.$Proxy2800.executeQuery(Unknown Source) [INFO] [talledLocalContainer] at com.codebarrel.data.api.jira.JiraDbConnectionManager.execute(JiraDbConnectionManager.java:32) [INFO] [talledLocalContainer] at com.codebarrel.jira.plugin.automation.store.JiraAutomationConfigStore.createRuleFromConfig(JiraAutomationConfigStore.java:184) [INFO] [talledLocalContainer] at com.codebarrel.jira.plugin.automation.store.JiraAutomationConfigStore.createRule(JiraAutomationConfigStore.java:162) [INFO] [talledLocalContainer] at com.codebarrel.jira.plugin.automation.store.CachingAutomationConfigStore.createRule(CachingAutomationConfigStore.java:81) [INFO] [talledLocalContainer] at com.codebarrel.automation.api.service.AutomationConfigServiceImpl.lambda$importRules$8(AutomationConfigServiceImpl.java:293) [INFO] [talledLocalContainer] at java.util.ArrayList.forEach(ArrayList.java:1249) [INFO] [talledLocalContainer] at com.codebarrel.automation.api.service.AutomationConfigServiceImpl.importRules(AutomationConfigServiceImpl.java:292) [INFO] [talledLocalContainer] at com.codebarrel.jira.plugin.automation.rest.RuleResource.importRules(RuleResource.java:179) [INFO] [talledLocalContainer] ... 3 filtered [INFO] [talledLocalContainer] at java.lang.reflect.Method.invoke(Method.java:498) [INFO] [talledLocalContainer] ... 19 filtered [INFO] [talledLocalContainer] at com.atlassian.plugins.rest.module.RestDelegatingServletFilter$JerseyOsgiServletContainer.doFilter(RestDelegatingServletFilter.java:154) [INFO] [talledLocalContainer] ... 1 filtered [INFO] [talledLocalContainer] at com.atlassian.plugins.rest.module.RestDelegatingServletFilter.doFilter(RestDelegatingServletFilter.java:68) [INFO] [talledLocalContainer] ... 32 filtered [INFO] [talledLocalContainer] at com.atlassian.servicedesk.internal.web.ExternalCustomerLockoutFilter.doFilter(ExternalCustomerLockoutFilter.java:56) [INFO] [talledLocalContainer] ... 13 filtered [INFO] [talledLocalContainer] at com.atlassian.web.servlet.plugin.request.RedirectInterceptingFilter.doFilter(RedirectInterceptingFilter.java:21) [INFO] [talledLocalContainer] ... 24 filtered [INFO] [talledLocalContainer] at com.atlassian.labs.httpservice.resource.ResourceFilter.doFilter(ResourceFilter.java:59) [INFO] [talledLocalContainer] ... 32 filtered [INFO] [talledLocalContainer] at com.atlassian.jira.security.JiraSecurityFilter.lambda$doFilter$0(JiraSecurityFilter.java:66) [INFO] [talledLocalContainer] ... 1 filtered [INFO] [talledLocalContainer] at com.atlassian.jira.security.JiraSecurityFilter.doFilter(JiraSecurityFilter.java:64) [INFO] [talledLocalContainer] ... 16 filtered [INFO] [talledLocalContainer] at com.atlassian.plugins.rest.module.servlet.RestSeraphFilter.doFilter(RestSeraphFilter.java:37) [INFO] [talledLocalContainer] ... 19 filtered [INFO] [talledLocalContainer] at com.atlassian.jira.servermetrics.CorrelationIdPopulatorFilter.doFilter(CorrelationIdPopulatorFilter.java:30) [INFO] [talledLocalContainer] ... 5 filtered [INFO] [talledLocalContainer] at com.atlassian.servicedesk.internal.web.CustomerContextSettingFilter.lambda$invokeFilterChain$0(CustomerContextSettingFilter.java:181) [INFO] [talledLocalContainer] at com.atlassian.servicedesk.internal.api.util.context.ReentrantThreadLocalBasedCodeContext.rteInvoke(ReentrantThreadLocalBasedCodeContext.java:137) [INFO] [talledLocalContainer] at com.atlassian.servicedesk.internal.api.util.context.ReentrantThreadLocalBasedCodeContext.runOutOfContext(ReentrantThreadLocalBasedCodeContext.java:90) [INFO] [talledLocalContainer] at com.atlassian.servicedesk.internal.utils.context.CustomerContextServiceImpl.runOutOfCustomerContext(CustomerContextServiceImpl.java:47) [INFO] [talledLocalContainer] at com.atlassian.servicedesk.internal.web.CustomerContextSettingFilter.outOfCustomerContext(CustomerContextSettingFilter.java:174) [INFO] [talledLocalContainer] at com.atlassian.servicedesk.internal.web.CustomerContextSettingFilter.doFilterImpl(CustomerContextSettingFilter.java:130) [INFO] [talledLocalContainer] at com.atlassian.servicedesk.internal.web.CustomerContextSettingFilter.doFilter(CustomerContextSettingFilter.java:121) [INFO] [talledLocalContainer] ... 4 filtered [INFO] [talledLocalContainer] at com.atlassian.jwt.internal.servlet.JwtAuthFilter.doFilter(JwtAuthFilter.java:32) [INFO] [talledLocalContainer] ... 8 filtered [INFO] [talledLocalContainer] at com.atlassian.web.servlet.plugin.request.RedirectInterceptingFilter.doFilter(RedirectInterceptingFilter.java:21) [INFO] [talledLocalContainer] ... 4 filtered [INFO] [talledLocalContainer] at com.atlassian.web.servlet.plugin.LocationCleanerFilter.doFilter(LocationCleanerFilter.java:36) [INFO] [talledLocalContainer] ... 26 filtered [INFO] [talledLocalContainer] at com.atlassian.jira.servermetrics.MetricsCollectorFilter.doFilter(MetricsCollectorFilter.java:25) [INFO] [talledLocalContainer] ... 21 filtered [INFO] [talledLocalContainer] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [INFO] [talledLocalContainer] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [INFO] [talledLocalContainer] at java.lang.Thread.run(Thread.java:745) [INFO] [talledLocalContainer] Caused by: org.postgresql.util.PSQLException: ERROR: insert or update on table "AO_589059_RULE_TO_LABEL" violates foreign key constraint "fk_ao_589059_rule_to_label_label_id" [INFO] [talledLocalContainer] Detail: Key (LABEL_ID)=(1324) is not present in table "AO_589059_RULE_LABEL". [INFO] [talledLocalContainer] at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2477) [INFO] [talledLocalContainer] at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2190) [INFO] [talledLocalContainer] at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:300) [INFO] [talledLocalContainer] at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:428) [INFO] [talledLocalContainer] at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:169) [INFO] [talledLocalContainer] at org.postgresql.jdbc.PgPreparedStatement.executeUpdate(PgPreparedStatement.java:136) [INFO] [talledLocalContainer] at org.apache.commons.dbcp2.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:98) [INFO] [talledLocalContainer] at org.apache.commons.dbcp2.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:98) [INFO] [talledLocalContainer] at com.querydsl.sql.dml.SQLInsertClause.execute(SQLInsertClause.java:423) [INFO] [talledLocalContainer] ... 291 more

Environment

None

Status

Assignee

Mark Chaimungkalanont

Reporter

Andreas Knecht

Links

0

Priority

Configure