Splunk Enterprise

xml dashboards 9.1.5 common.js error

LY
Loves-to-Learn

Hey,

I have a problem after upgrading to 9.1.5 from 9.0.4 (enterprise)
all the dashboards that have tokenlinks.js from "simple_xml_examples" (splunk dashboard examples) app ,the latest version

have the following error and the script don't work :
"  A custom JavaScript error caused an issue loading your dashboard. See the developer console for more details.  "

in the dev-tool F12 I sew the error comes from common.js :

"  Refused to execute script from/en-US/static/@29befd543def.77/js/util/console.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.


common.js:1702 Error: Script error for: util/console
http://requirejs.org/docs/errors.html#scripterror
     at makeError (eval at e.exports (common.js:502:244924), <anonymous>:166:17)
     at HTMLScriptElement.onScriptError (eval at e.exports (common.js:502:244924), <anonymous>:1689:36)  "

someone have any idea why or how to fix it?

Thanks!

Splunk Dashboard Examples Dashboard 

0 Karma

tscroggins
Influencer

Hi @LY,

The MIME type error should have been preceded by a status 404. console.js has been removed (technically, quarantined) from current versions of Splunk Enterprise.

All modern browsers should have a native console object, and you can remove the util/console requirement from tokenlinks.js:

--- tokenlinks.js.original      2024-09-23 19:40:34.985325558 -0400
+++ tokenlinks.js       2024-09-23 19:40:59.456196826 -0400
@@ -1,10 +1,9 @@
 requirejs([
     '../app/simple_xml_examples/libs/jquery-3.6.0-umd-min',
     '../app/simple_xml_examples/libs/underscore-1.6.0-umd-min',
-    'util/console',
     'splunkjs/mvc',
     'splunkjs/mvc/simplexml/ready!'
-], function($, _, console, mvc) {
+], function($, _, mvc) {

     function setToken(name, value) {
         console.log('Setting Token %o=%o', name, value);
@@ -51,4 +50,4 @@
             }
         }
     });
-});
\ No newline at end of file
+});

 You can also remove the console.log() and console.warn() lines if you don't need them.

0 Karma

LY
Loves-to-Learn

Thank You!
I don't think I can remove the last  console.warn() because the 'try 'of the  Unset token is depend on it
so now the error don't appear on the dashboard but the unset token not working 😕

Is there a way to unquarantine the console.js from the SH?

0 Karma

tscroggins
Influencer

The console lines just print diagnostic messages. All modern browsers have a console object, so you can leave them if you want. If you do remove them, an empty catch block won't cause any problems.

The rest of the sample code just responds to click events. Looking at the custom_token_links dashboard example, you can see how this is done:

 

<a href="#" class="btn-pill" data-set-token="show_chart" data-value="show" data-unset-token="show_table">
  Show Chart
</a>

 

When you click on Show Chart, the click event hander is called, explicitly passing the data-set-token and data-unset-token values.

In this example, data-unset-token is set to show_table, and the click handler sets the show_table token value to undefined. Because the table has a dependency on $show_table$, the table is hidden when show_table is undefined.

If you can post a representative copy of the broken dashboard, we can probably fix it.

0 Karma
Get Updates on the Splunk Community!

Prove Your Splunk Prowess at .conf25—No Prereqs Required!

Your Next Big Security Credential: No Prerequisites Needed We know you’ve got the skills, and now, earning the ...

Splunk Observability Cloud's AI Assistant in Action Series: Observability as Code

This is the sixth post in the Splunk Observability Cloud’s AI Assistant in Action series that digs into how to ...

Splunk Answers Content Calendar, July Edition I

Hello Community! Welcome to another month of Community Content Calendar series! For the month of July, we will ...