How to troubleshoot client-side problems when editing an issue
Platform Notice: Data Center - This article applies to Atlassian products on the Data Center platform.
Note that this knowledge base article was created for the Data Center version of the product. Data Center knowledge base articles for non-Data Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Problem
When opening an issue at the View Issue screen, one of the following deviations may be observed:
- Adding a comment - the page spins but the comment was added
- Transition (any) - the page spins - but the transition is done
- The fields are not available for edition (the small pencil visible on each field) and for changing, requires clicking at the Edit button;
- We can observe errors on the page or on the Javascript console like:
- Uncaught TypeError: cannot read property 'setAttribute' of null
- Uncaught TypeError: Cannot read property of undefined (reading 'ajaxSetup')
- Uncaught TypeError: Cannot read property 'fields' (or 'html') of undefined"
Diagnostics:
Confirm that the issue is occurring only at the Client-side:
Reproduce the issue while collecting the following:
Access logs ( either from Tomcat or reverse-proxy / load balancer )
Follow the user action - From the Har file, identify the user request, review the request from the access logs, and follow its execution using the support.zip and thread dumps:
- Har file: Identify the node, user Request ID, Session ID, and the time spent on each activity (blocked at the Browser side, sending data to the server, waiting or receiving data from the server):
Post /rest/api/2/issue/IS-75390/comment
X-AREQUESTID 735x8504x1
X-ASESSIONID gtu5rq
X-ANODEID node01"timings": {
"blocked": 1.1609999644048512,
"dns": -1,
"ssl": -1,
"connect": -1,
"send": 0.121,
"wait": 2738.101999992367,
"receive": 0.7910000276751816,
"_blocked_queueing": 0.9049999644048512
}
- Access logs:
- Search for the request, using the request executed, date, time, request ID (735x8504x1), and the Session ID (gtu5rq) on the access logs from the node where the request was processed.
- Observe the status code of the request (%s), if it was 200, and the Time taken to process the request in ms (%D).
- Use the valve definition in the Server.xml file to find the correct position of these values at the Access.log:
- Access logs:
<Valve className="org.apache.catalina.valves.AccessLogValve"
pattern="%{x-forwarded-for}i via %a %{jira.request.id}r %{jira.request.username}r %t "%m %U%q %H" %s %b %D "%{Referer}i" "%{User-Agent}i" "%{jira.request.assession.id}r""/>
- Support.zip: Confirm that there are no ERROR, WARN related to the request ID (735x8504x1) and the Session ID (gtu5rq) on the support.zip logs;
2021-01-06 12:15:43,255-0500 https-jsse-nio-8443-exec-15 url:/rest/api/2/issue/IS-75390/comment username:xxxxxx INFO xxxx 735x8504x1 gtu5rq
/rest/api/2/issue/IS-75390/comment [c.a.jira.index.MonitoringIndexWriter] [lucene-stats] flush stats: snapshotCount=6, totalCount=50, periodSec=574, flushIntervalMillis=95714,
snapshotNoDocs=0, totalNoDocs=0, indexDirectory=/opt/atlassian/jira-data/caches/indexesV1/issues, indexWriterId=com.atlassian.jira.index.MonitoringIndexWriter@14c12553, indexDirectoryId=MMapDirectory@/opt/atlassian/jira-data/caches/indexesV1/issues lockFactory=org.apache.lucene.store.NativeFSLockFactory@189844a6
- Thread Dumps: Confirm that the Tomcat HTTP thread (on the sample, https-jsse-nio-8443-exec-15) had not remained longer during the Thread Capture;
- Browser: While the request at the Browser is spinning, open a separate browser and view the same issue: Observe if the change was already done;
- Browser: While the request at the Browser is spinning, open a separate browser and view the same issue: Observe if the change was already done;
2. Temporarily disable Add-ons, running in safe mode, and check if the issue is still reproducible.
- If it is not more reproducible, observe which plugins were accessed at the har file and do multiple tests disabling each plugin one per time.
3. Temporarily disable HTML in custom field descriptions
- In Jira Admin -> System, set the option "Enable HTML in custom field descriptions and list item values" to OFF and test if the issue is still reproducible.
4. Inspect Javascript Console:
- Enable the Developer Tools panel and open the Console tab.
- Observe if an error is triggered when the issue is reproduced:
uncaught TypeError: cannot read property 'setAttribute' of null
at eval (eval at globalEval (batch.js?locale=en-US:43), <anonymous>:1:45)
at eval (<anonymous>)
at Function.globalEval (batch.js?locale=en-US:43)
at xe (batch.js?locale=en-US:54_
at c.fn.init.append (batch.js?locale=en-US:54)
at c.fn.init.e.fn.<computed> [as append] (batch.js?agile.globa...chediton=true:22582)
at d.createFieldView (batch.js?agile_globa..chediton=true:25305)
at A (batch.js?locale=en-US:959_
at d.trigger (batch.js?locale=en-US:957)
at d._onModelEvent (batch.js?locale=en-US:976)
- Add Breakpoints by clicking at the link (batch.js?locale=en-US:43) to open the javascript code at the Source panel. Click over the line number to add the Breakpoint;
Reproduce again the issue, it will interrupt the execution at the Breakpoint. Inspect the code, if it is possible to identify what it was doing or if it is related to a specific field;
5. Database Queries:
- Identify which Custom Fields or Fields are customized, running the following queries:
The following query checks the descriptions of custom fields for scripts:
select * from customfield
where lower(cast(description as varchar)) like '%<javascript%'
or lower(cast(description as varchar)) like '%<script%'
or lower(cast(description as varchar)) like '%html%'
or lower(cast(description as varchar)) like '%css%';
Custom fields can also have alternate descriptions specified by field configurations:
select * from fieldlayoutitem
where lower(cast(description as varchar)) like '%<javascript%'
or lower(cast(description as varchar)) like '%<script%'
or lower(cast(description as varchar)) like '%html%'
or lower(cast(description as varchar)) like '%css%';
The following queries check for any scripts in custom field contexts:
select * from fieldconfigscheme
where lower(cast(description as varchar)) like '%<javascript%'
or lower(cast(description as varchar)) like '%<script%'
or lower(cast(description as varchar)) like '%html%'
or lower(cast(description as varchar)) like '%css%';
select * from fieldconfiguration
where lower(cast(description as varchar)) like '%<javascript%'
or lower(cast(description as varchar)) like '%<script%'
or lower(cast(description as varchar)) like '%html%'
or lower(cast(description as varchar)) like '%css%';
It can also be worth checking the announcement banner for any scripts, as it's a known potential cause of interference when it contains custom scripts or HTML code:
select * from propertytext
where id in (select id from propertyentry
where property_key='jira.alertheader');
Here are the same queries above all in one block for easier copying and pasting:
select * from customfield
where lower(cast(description as varchar)) like '%<javascript%'
or lower(cast(description as varchar)) like '%<script%'
or lower(cast(description as varchar)) like '%html%'
or lower(cast(description as varchar)) like '%css%';
select * from fieldlayoutitem
where lower(cast(description as varchar)) like '%<javascript%'
or lower(cast(description as varchar)) like '%<script%'
or lower(cast(description as varchar)) like '%html%'
or lower(cast(description as varchar)) like '%css%';
select * from fieldconfigscheme
where lower(cast(description as varchar)) like '%<javascript%'
or lower(cast(description as varchar)) like '%<script%'
or lower(cast(description as varchar)) like '%html%'
or lower(cast(description as varchar)) like '%css%';
select * from fieldconfiguration
where lower(cast(description as varchar)) like '%<javascript%'
or lower(cast(description as varchar)) like '%<script%'
or lower(cast(description as varchar)) like '%html%'
or lower(cast(description as varchar)) like '%css%';
select * from propertytext
where id in (select id from propertyentry
where property_key='jira.alertheader');
Workarounds
1. Find and remove or fix the problematic Javascript:
- Observe if the error observed at the Javascript Console can be found on one of the results returned:
id | fieldlayout | fieldidentifier | description | verticalposition | ishidden | isrequired | renderertype |
---|---|---|---|---|---|---|---|
6712049 | 37300 | customfield_13102 | <script type="text/javascript"> document.getElementById("customfield_13102").setAttribute('maxlength',80); </script> | false | true | jira-text-renderer |
- Identify which is the Custom field, using the number at the "fieldidentifier" at the URL to edit the Custom Field:
<your Jira base URL>/secure/admin/EditCustomField!default.jspa?id=13102
- Edit the Description:
- Choose > Issues.
- Select Fields > Field Configurations to open the View Field Configurations page, which lists all your field configurations.
- Locate the field configuration of interest and click the Configure link to open the View Field Configuration page, which lists all system and custom fields in your JIRA installation for that field configuration.
- Click the Edit link next to the field you want to change and fix the javascript.
- Click the Update button to save your changes.
2. Use the Announcement Banner to define javascript variables
- When Jira Admin does not want to update the Database to clear the scripts or when it is not possible to browse the FieldConfiguration or CustomField page altogether because the script executes there as well and the config page fails to load, we can analyze the error occurring and add a script at the announcement banner to work around it.
For instance, on the sample, the error occurring is:
uncaught TypeError: cannot read property 'setAttribute' of null
And the script:
<script type="text/javascript">
document.getElementById("customfield_13102").setAttribute('maxlength',80);
</script>
- The error is occurring because it is trying to get the element document.getElementById("customfield_13102") before the page has been loaded completely. The get call to the element returns a null, causing the evaluator to fail as null does not have the setAttribute() method.
- In this case, a valid workaround would be to inject an element with that ID into the announcement banner as the banner division of the page is loaded first, thus making sure this element already exists when the script is executed:
var inputBox = $('<input>').attr("type", "text").attr("id","customfield_13102);
inputBox.appendTo('#announcement-banner');