Uploaded image for project: 'camunda BPM'
  1. camunda BPM
  2. CAM-7906

Improve error message when user submits variable value which exceeds max size




      Current behavior
      When a user submits a String value for a variable which does not fit the maximum capacity of the TEXT_ column in the variable table, then a low-level database error is thrown. See Example at the end of this Description

      This error looks scary and results in poor usability of the API and confuses people.

      Desired behavior
      Since this is effectively a validation error, it would be better if the user would get a more appropriate error

      Implementation Hints:

      It may not be a good idea to simply validate the length of the string in Java, because

      • The varchar is defined in bytes, not characters. The number of characters which can fit into the column varies on the encoding but also the characters themselves. This only leaves the option to use conservative/worstcase value, ie. in worstcase, VARCHAR(4000) will fit amount X of characters.
      • However, this is also bad since it may break applications which already use the API and are now able to successfully store an amount X of characters which is larger than the worst case scenario but still within the bounds of what can be stored.
      • Also, this may vary depending on the database

      Example Error

      ### Error updating database.  Cause: org.postgresql.util.PSQLException: ERROR: value too long for type character varying(4000)
      ### The error may involve org.camunda.bpm.engine.impl.persistence.entity.HistoricVariableInstanceEntity.insertHistoricVariableInstance-Inline
      ### The error occurred while setting parameters
      ### SQL: insert into ACT_HI_VARINST (       ID_,       PROC_DEF_KEY_,       PROC_DEF_ID_,       PROC_INST_ID_,       EXECUTION_ID_,       ACT_INST_ID_,       TENANT_ID_,       CASE_DEF_KEY_,       CASE_DEF_ID_,       CASE_INST_ID_,       CASE_EXECUTION_ID_,       TASK_ID_,       NAME_,       REV_,       VAR_TYPE_,       BYTEARRAY_ID_,       DOUBLE_,       LONG_,       TEXT_,       TEXT2_     ) values (       ?,       ?,       ?,       ?,       ?,       ?,       ?,       ?,       ?,       ?,       ?,       ?,       ?,       ?,       ?,       ?,       ?,       ?,       ?,       ?     )
      ### Cause: org.postgresql.util.PSQLException: ERROR: value too long for type character varying(4000)'. Flush summary:
        INSERT HistoricVariableInstanceEntity[7d3b8ed3-46cb-11e7-88bb-5254005fa31e]
        INSERT HistoricJobLogEventEntity[7d3d6398-46cb-11e7-88bb-5254005fa31e]
        INSERT HistoricVariableUpdateEventEntity[7d3b8ed4-46cb-11e7-88bb-5254005fa31e]
        INSERT HistoricVariableUpdateEventEntity[7d3bdcf5-46cb-11e7-88bb-5254005fa31e]
        INSERT HistoricVariableUpdateEventEntity[7d3d1576-46cb-11e7-88bb-5254005fa31e]
        INSERT VariableInstanceEntity[7d3b8ed3-46cb-11e7-88bb-5254005fa31e]
        INSERT MessageEntity[7d3d6397-46cb-11e7-88bb-5254005fa31e]
        DELETE ExternalTaskEntity[2aa0aa57-46ca-11e7-88bb-5254005fa31e]
        UPDATE VariableInstanceEntity[2a944f0c-46ca-11e7-88bb-5254005fa31e]
        DELETE VariableInstanceEntity[2aa03607-46ca-11e7-88bb-5254005fa31e]
        DELETE VariableInstanceEntity[2aa03609-46ca-11e7-88bb-5254005fa31e]
        DELETE VariableInstanceEntity[2aa0360c-46ca-11e7-88bb-5254005fa31e]
        DELETE VariableInstanceEntity[2aa0360e-46ca-11e7-88bb-5254005fa31e]
        DELETE VariableInstanceEntity[2aa08331-46ca-11e7-88bb-5254005fa31e]
        DELETE VariableInstanceEntity[2aa08337-46ca-11e7-88bb-5254005fa31e]
        DELETE VariableInstanceEntity[2aa08339-46ca-11e7-88bb-5254005fa31e]
        DELETE VariableInstanceEntity[2aa0833b-46ca-11e7-88bb-5254005fa31e]
        DELETE VariableInstanceEntity[2aa0833d-46ca-11e7-88bb-5254005fa31e]
        DELETE VariableInstanceEntity[2aa0833f-46ca-11e7-88bb-5254005fa31e]
        DELETE VariableInstanceEntity[2aa08341-46ca-11e7-88bb-5254005fa31e]
        DELETE VariableInstanceEntity[2aa08343-46ca-11e7-88bb-5254005fa31e]
        DELETE VariableInstanceEntity[2aa08345-46ca-11e7-88bb-5254005fa31e]
        DELETE ByteArrayEntity[2aa08330-46ca-11e7-88bb-5254005fa31e]
        UPDATE ExecutionEntity[ed79e975-46c9-11e7-88bb-5254005fa31e]
        DELETE ExecutionEntity[2aa08335-46ca-11e7-88bb-5254005fa31e]
        DELETE ExecutionEntity[2a9f2490-46ca-11e7-88bb-5254005fa31e]
        UPDATE HistoricActivityInstanceEventEntity[2a9f4ba1-46ca-11e7-88bb-5254005fa31e]
        UPDATE HistoricActivityInstanceEventEntity[Task_03cybm7:2aa08336-46ca-11e7-88bb-5254005fa31e]
        UPDATE HistoricVariableInstanceEntity[2a944f0c-46ca-11e7-88bb-5254005fa31e]
        UPDATE HistoricVariableInstanceEntity[2aa03609-46ca-11e7-88bb-5254005fa31e]
       org.camunda.bpm.engine.ProcessEngineException: ENGINE-03004 Exception while executing Database Operation 'INSERT HistoricVariableInstanceEntity[7d3b8ed3-46cb-11e7-88bb-5254005fa31e]' with message '


        This is the controller panel for Smart Panels app




              roman.smirnov Roman Smirnov
              meyer Daniel Meyer
              0 Vote for this issue
              4 Start watching this issue