Uploaded image for project: 'Jira Software Data Center'
  1. Jira Software Data Center
  2. JSWSERVER-26404

Advanced Roadmaps plan doesn't show up when date fields have erroneous data

XMLWordPrintable

      Problem

      Advanced Roadmaps plan stops showing up and a blank screen is presented to the user at the same time at the developer tools console it shows the exception bellow when the date/time fields have wrong values that can't be processed .

      The main problem is that users can introduce custom configurations on Jira's main menu as in Configuring Time and Date Formats where the date format follows a specific pattern or language that Advanced Roadmaps fails to follow at plan display time .

      As an example setting a target start/end value as "12/May/25" from Jira's edit screen makes ARJ assume the year as 0025 and not 2025

      Stack Trace
      Uncaught RangeError: Invalid time value
      
      RangeError: Invalid time value
          at t.default (https://HOST/jira/s/d41d8cd98f00b204e9800998ecf8427e-CDN/-34gf00/10040002/1bqcfwe/10.4.1/_/download/batch/com.atlassian.jpo:jpo-wr-page-portfolio-frontend-vendor-scripts/com.atlassian.jpo:jpo-wr-page-portfolio-frontend-vendor-scripts.js:18:316311)
          at s (https://HOST/jira/s/d41d8cd98f00b204e9800998ecf8427e-CDN/-34gf00/10040002/1bqcfwe/10.4.1/_/download/batch/com.atlassian.jpo:jpo-wr-page-portfolio-frontend-vendor-scripts/com.atlassian.jpo:jpo-wr-page-portfolio-frontend-vendor-scripts.js:22:347899)
          at i (https://HOST/jira/s/d41d8cd98f00b204e9800998ecf8427e-CDN/-34gf00/10040002/1bqcfwe/10.4.1/_/download/batch/com.atlassian.jpo:jpo-wr-page-portfolio-frontend-vendor-scripts/com.atlassian.jpo:jpo-wr-page-portfolio-frontend-vendor-scripts.js:22:348116)
      
      

      Steps to Reproduce

      • Configure jira.date.picker.java.format to d/MMM/yyyy
      • Configure jira.date.time.picker.java.format to dd/MMM/yyyy h:mm a
      • Configure the look and feel JavaScript picker date format to use yyyy dates.
      • Add the date field or target start/end field to the issue view and edit it to a value of YY instead of YYYY , which will result in to value of {"baseline_start":"-61448716800000",""baseline_end":"-61446988800000"} at entity_property.json_value column
      • Visit a plan that relies on the date field 

      Expected Results

      • The plan uses Jira's global configuration and adjusts the date display
      • The Advanced Roadmaps plan will open and show an alert on the date value if the converted timestamp doesn't make sense

      Actual Results

      • The plan stops loading, and Jira presents a blank screen when the JavaScript function throws an exception in treating the wrong date value formatting

      Workaround

      • Avoid editing the date fields from Jira's editing screen and use ARJ's plan to set the date value

      If there are already entries that prevent the screen from appearing :

      Use this query to see how many impacted entries there are (this query checks only the Target start/end field). The query is applicable to the PostgreSQL database.

      SELECT COUNT(*)
      FROM entity_property
      WHERE property_key = 'jpo-issue-properties'
      AND json_value IS NOT NULL
      AND (
          -- Only update when at least one value is outside the bounds
          (json_value::json->>'baseline_start')::numeric < 0
          OR (json_value::json->>'baseline_start')::numeric > 190000000000000
          OR (json_value::json->>'baseline_end')::numeric < 0
          OR (json_value::json->>'baseline_end')::numeric > 190000000000000
      ); 

      The following query updates the impacted entries

      UPDATE entity_property
      SET json_value = 
          CASE 
              -- When both baseline_start and baseline_end exist
              WHEN json_value::json->>'baseline_start' IS NOT NULL 
                   AND json_value::json->>'baseline_end' IS NOT NULL
              THEN (
                  json_value::jsonb || 
                  jsonb_build_object(
                      'baseline_start', 
                      CASE 
                          WHEN (json_value::json->>'baseline_start')::numeric < 0 THEN '0'
                          WHEN (json_value::json->>'baseline_start')::numeric > 190000000000000 THEN '0'
                          ELSE json_value::json->>'baseline_start'
                      END,
                      'baseline_end',
                      CASE 
                          WHEN (json_value::json->>'baseline_end')::numeric < 0 THEN '0'
                          WHEN (json_value::json->>'baseline_end')::numeric > 190000000000000 THEN '0'
                          ELSE json_value::json->>'baseline_end'
                      END
                  )
              )::text
              -- When only baseline_start exists
              WHEN json_value::json->>'baseline_start' IS NOT NULL
              THEN (
                  json_value::jsonb || 
                  jsonb_build_object(
                      'baseline_start',
                      CASE 
                          WHEN (json_value::json->>'baseline_start')::numeric < 0 THEN '0'
                          WHEN (json_value::json->>'baseline_start')::numeric > 190000000000000 THEN '0'
                          ELSE json_value::json->>'baseline_start'
                      END
                  )
              )::text
              -- When only baseline_end exists
              WHEN json_value::json->>'baseline_end' IS NOT NULL
              THEN (
                  json_value::jsonb || 
                  jsonb_build_object(
                      'baseline_end',
                      CASE 
                          WHEN (json_value::json->>'baseline_end')::numeric < 0 THEN '0'
                          WHEN (json_value::json->>'baseline_end')::numeric > 190000000000000 THEN '0'
                          ELSE json_value::json->>'baseline_end'
                      END
                  )
              )::text
              -- When neither exists, keep the original value
              ELSE json_value
          END
      WHERE property_key = 'jpo-issue-properties'
      AND json_value IS NOT NULL
      AND (
          -- Only update when at least one value is outside the bounds
          (json_value::json->>'baseline_start')::numeric < 0
          OR (json_value::json->>'baseline_start')::numeric > 190000000000000
          OR (json_value::json->>'baseline_end')::numeric < 0
          OR (json_value::json->>'baseline_end')::numeric > 190000000000000
      );
      
      

      Notes

      The update query execution time depends on the number of impacted entries and db host capacity

      IMPORTANT

      Always back up your data before performing any modifications to the database. If possible, test any alter, insert, update, or delete SQL commands on a staging server first.

       

              Unassigned Unassigned
              f0ea184c9b1c Mohamed Kouki (Inactive)
              Votes:
              4 Vote for this issue
              Watchers:
              8 Start watching this issue

                Created:
                Updated: