Uploaded image for project: 'Jira Data Center'
  1. Jira Data Center
  2. JRASERVER-70398

When using PostgreSQL and passing null character to text custom field during issue creation results with failure

    XMLWordPrintable

Details

    • Bug
    • Resolution: Timed out
    • Medium
    • None
    • 8.0.0, 7.6.15, 7.13.9, 8.5.0, 8.5.1
    • None

    Description

      Issue Summary

      PostgreSQL database doesn't allow null (\0) character to be saved as text field (link). This is not correctly handled by Jira's ORM.

      The issue by itself should only make it impossible to save the issue with the incorrect data, but it is also a trigger for JRASERVER-70333.

      Steps to Reproduce

      1. Set up Jira on PostgreSQL database,
      2. Create new project,
      3. Create new text custom field and add it to issue scheme for this project,
      4. Generate any non empty string which is not allowed by the PostgreSQL, for instance:
        • based on this generate string with empty character,
        • open developer tools in you browser,
        • in console invoke "console.log('a\0a')" function(the output will be "aa" but for real there will be an empty character between the 'a' letters),
        • copy paste the output to the custom field,
      5. Try to create the issue
      6. Check the log

      Expected Results

      Either:

      • The problem is handled by ORM
      • Null character is forbidden on the field validator level
      • Null character is removed from the field

      Actual Results

      Error message presented to the user reads as follows:

      We can't create this issue for you right now, it could be due to unsupported content you've entered into one or more of the issue fields. If this situation persists, contact your administrator as they'll be able to access more specific information in the log file.
      

      In the Jira log files you can find out stack trace:

      2019-11-28 18:00:57,957 http-nio-8080-exec-1 ERROR admin 1080x778x1 1t82g3q 0:0:0:0:0:0:0:1 /secure/QuickCreateIssue.jspa [c.a.j.bc.issue.DefaultIssueService] Error creating issue:
      com.atlassian.jira.exception.CreateException: org.ofbiz.core.entity.GenericEntityException: while inserting: [GenericEntity:CustomFieldValue][parentkey,null][customfield,10101][issue,10135][stringvalue,aa][id,10141][updated,1574960457955] (SQL Exception while executing the following:INSERT INTO public.customfieldvalue (ID, ISSUE, CUSTOMFIELD, UPDATED, PARENTKEY, STRINGVALUE, NUMBERVALUE, TEXTVALUE, DATEVALUE, VALUETYPE) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) (ERROR: invalid byte sequence for encoding "UTF8": 0x00))
      	at com.atlassian.jira.issue.managers.DefaultIssueManager.createIssue(DefaultIssueManager.java:592)
      	at com.atlassian.jira.issue.managers.DefaultIssueManager.createIssue(DefaultIssueManager.java:498)
      	at com.atlassian.jira.issue.managers.RequestCachingIssueManager.createIssue(RequestCachingIssueManager.java:192)
      	at com.atlassian.jira.bc.issue.DefaultIssueService.create(DefaultIssueService.java:238)
      	at com.atlassian.jira.bc.issue.DefaultIssueService.create(DefaultIssueService.java:207)
      	... 2 filtered
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at com.atlassian.plugin.util.ContextClassLoaderSettingInvocationHandler.invoke(ContextClassLoaderSettingInvocationHandler.java:26)
      	at com.sun.proxy.$Proxy220.create(Unknown Source)
      	... 2 filtered
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at com.atlassian.plugin.osgi.bridge.external.HostComponentFactoryBean$DynamicServiceInvocationHandler.invoke(HostComponentFactoryBean.java:136)
      	at com.sun.proxy.$Proxy220.create(Unknown Source)
      	at com.atlassian.jira.quickedit.action.QuickCreateIssue.doExecute(QuickCreateIssue.java:308)
      	... 1 filtered
      	at com.atlassian.jira.action.JiraActionSupport.execute(JiraActionSupport.java:63)
      	... 7 filtered
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
      	... 48 filtered
      	at com.atlassian.greenhopper.jira.filters.ClassicBoardRouter.doFilter(ClassicBoardRouter.java:62)
      	... 12 filtered
      	at com.atlassian.web.servlet.plugin.request.RedirectInterceptingFilter.doFilter(RedirectInterceptingFilter.java:21)
      	... 58 filtered
      	at com.atlassian.jira.security.JiraSecurityFilter.lambda$doFilter$0(JiraSecurityFilter.java:66)
      	... 1 filtered
      	at com.atlassian.jira.security.JiraSecurityFilter.doFilter(JiraSecurityFilter.java:64)
      	... 39 filtered
      	at com.atlassian.jira.servermetrics.CorrelationIdPopulatorFilter.doFilter(CorrelationIdPopulatorFilter.java:30)
      	... 10 filtered
      	at com.atlassian.web.servlet.plugin.request.RedirectInterceptingFilter.doFilter(RedirectInterceptingFilter.java:21)
      	... 4 filtered
      	at com.atlassian.web.servlet.plugin.LocationCleanerFilter.doFilter(LocationCleanerFilter.java:36)
      	... 26 filtered
      	at com.atlassian.jira.servermetrics.MetricsCollectorFilter.doFilter(MetricsCollectorFilter.java:25)
      	... 24 filtered
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
      	at java.lang.Thread.run(Thread.java:748)
      Caused by: com.atlassian.jira.workflow.WorkflowException: org.ofbiz.core.entity.GenericEntityException: while inserting: [GenericEntity:CustomFieldValue][parentkey,null][customfield,10101][issue,10135][stringvalue,aa][id,10141][updated,1574960457955] (SQL Exception while executing the following:INSERT INTO public.customfieldvalue (ID, ISSUE, CUSTOMFIELD, UPDATED, PARENTKEY, STRINGVALUE, NUMBERVALUE, TEXTVALUE, DATEVALUE, VALUETYPE) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) (ERROR: invalid byte sequence for encoding "UTF8": 0x00))
      	at com.atlassian.jira.workflow.OSWorkflowManager.createIssue(OSWorkflowManager.java:768)
      	at com.atlassian.jira.issue.managers.DefaultIssueManager.createIssue(DefaultIssueManager.java:584)
      	... 259 more
      Caused by: com.atlassian.jira.exception.DataAccessException: org.ofbiz.core.entity.GenericEntityException: while inserting: [GenericEntity:CustomFieldValue][parentkey,null][customfield,10101][issue,10135][stringvalue,aa][id,10141][updated,1574960457955] (SQL Exception while executing the following:INSERT INTO public.customfieldvalue (ID, ISSUE, CUSTOMFIELD, UPDATED, PARENTKEY, STRINGVALUE, NUMBERVALUE, TEXTVALUE, DATEVALUE, VALUETYPE) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) (ERROR: invalid byte sequence for encoding "UTF8": 0x00))
      	at com.atlassian.jira.ofbiz.DefaultOfBizDelegator.createValue(DefaultOfBizDelegator.java:299)
      	at com.atlassian.jira.issue.customfields.persistence.OfBizCustomFieldValuePersister.createValuesInt(OfBizCustomFieldValuePersister.java:129)
      	at com.atlassian.jira.issue.customfields.persistence.OfBizCustomFieldValuePersister.updateValues(OfBizCustomFieldValuePersister.java:154)
      	at com.atlassian.jira.issue.customfields.persistence.EagerLoadingOfBizCustomFieldPersister.updateValues(EagerLoadingOfBizCustomFieldPersister.java:54)
      	at com.atlassian.jira.issue.customfields.persistence.OfBizCustomFieldValuePersister.createValues(OfBizCustomFieldValuePersister.java:109)
      	at com.atlassian.jira.issue.customfields.persistence.EagerLoadingOfBizCustomFieldPersister.createValues(EagerLoadingOfBizCustomFieldPersister.java:42)
      	at com.atlassian.jira.issue.customfields.persistence.OfBizCustomFieldValuePersister.createValues(OfBizCustomFieldValuePersister.java:102)
      	at com.atlassian.jira.issue.customfields.persistence.EagerLoadingOfBizCustomFieldPersister.createValues(EagerLoadingOfBizCustomFieldPersister.java:36)
      	at com.atlassian.jira.issue.customfields.impl.AbstractSingleFieldType.createValue(AbstractSingleFieldType.java:143)
      	at com.atlassian.jira.issue.fields.ImmutableCustomField.createValue(ImmutableCustomField.java:693)
      	at com.atlassian.jira.workflow.function.issue.IssueCreateFunction.execute(IssueCreateFunction.java:81)
      	at com.opensymphony.workflow.AbstractWorkflow.executeFunction(AbstractWorkflow.java:1014)
      	at com.opensymphony.workflow.AbstractWorkflow.transitionWorkflow(AbstractWorkflow.java:1407)
      	at com.opensymphony.workflow.AbstractWorkflow.initialize(AbstractWorkflow.java:606)
      	at com.atlassian.jira.workflow.OSWorkflowManager.createIssue(OSWorkflowManager.java:742)
      	... 260 more
      Caused by: org.ofbiz.core.entity.GenericEntityException: while inserting: [GenericEntity:CustomFieldValue][parentkey,null][customfield,10101][issue,10135][stringvalue,aa][id,10141][updated,1574960457955] (SQL Exception while executing the following:INSERT INTO public.customfieldvalue (ID, ISSUE, CUSTOMFIELD, UPDATED, PARENTKEY, STRINGVALUE, NUMBERVALUE, TEXTVALUE, DATEVALUE, VALUETYPE) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) (ERROR: invalid byte sequence for encoding "UTF8": 0x00))
      	at org.ofbiz.core.entity.GenericDAO.singleInsert(GenericDAO.java:206)
      	at org.ofbiz.core.entity.GenericDAO.insert(GenericDAO.java:171)
      	at org.ofbiz.core.entity.GenericHelperDAO.create(GenericHelperDAO.java:89)
      	at org.ofbiz.core.entity.GenericDelegator.create(GenericDelegator.java:562)
      	at org.ofbiz.core.entity.GenericDelegator.create(GenericDelegator.java:548)
      	at com.atlassian.jira.ofbiz.DefaultOfBizDelegator.createValue(DefaultOfBizDelegator.java:296)
      	... 275 more
      Caused by: org.ofbiz.core.entity.GenericDataSourceException: SQL Exception while executing the following:INSERT INTO public.customfieldvalue (ID, ISSUE, CUSTOMFIELD, UPDATED, PARENTKEY, STRINGVALUE, NUMBERVALUE, TEXTVALUE, DATEVALUE, VALUETYPE) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) (ERROR: invalid byte sequence for encoding "UTF8": 0x00)
      	at org.ofbiz.core.entity.jdbc.SQLProcessor.executeUpdate(SQLProcessor.java:570)
      	at org.ofbiz.core.entity.GenericDAO.singleInsert(GenericDAO.java:198)
      	... 281 more
      Caused by: org.postgresql.util.PSQLException: ERROR: invalid byte sequence for encoding "UTF8": 0x00
      	at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2455)
      	at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:288)
      	at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:430)
      	at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:356)
      	at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:168)
      	at org.postgresql.jdbc.PgPreparedStatement.executeUpdate(PgPreparedStatement.java:135)
      	at org.apache.commons.dbcp2.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:98)
      	at org.apache.commons.dbcp2.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:98)
      	at org.ofbiz.core.entity.jdbc.SQLProcessor.executeUpdate(SQLProcessor.java:562)
      	... 282 more
      

      Workaround

      Create custom plugin which will add validator to creation workflow. More info can be found here.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              pczuj Przemyslaw Czuj
              Votes:
              1 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: