Instance Scan Linter Check Rhino Error
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
I'm trying to create a linter check to scan for client scripts on a fresh Australia PDI but am always getting the following Failure.
Rhino error: missing ; before statement
I've stripped the linter check script to a barebones version to see if I still get the failure, and I do.
(function (engine) {
var TABLES_TO_CHECK = ["sys_script_client"];
if (TABLES_TO_CHECK.indexOf(String(engine.current.getTableName())) == -1) {
return;
}
gs.info(new GlideDateTime().getNumericValue() + " Current script being checked: " + engine.current.getValue("name") + " " + engine.current.sys_id);
})(engine);
Is there a way to print a stack trace to see what segment of code is causing this error?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi there,
Don't see any error in the code visually, will try to reproduce on a PDI.
Is this just a test or what are you after with your check? Asking because seeing the tables_to_check, this is a very inefficient use of Instance Scan, since Linter Check will still run on every table with script fields. So instead of a table check that would run in a few seconds, this linter check will run for several minutes on larger instances or even time-out.
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 2 weeks ago
Hi Mark,
Thanks for your reply. As you mentioned, the linter check does take an excruciatingly long amount of time because it is scanning every table with a script field. However, in my actual linter check script, I am trying to make use of abstract syntax trees to find instances of deprecated API calls within client scripts. As far as I could see in the documentation, it seemed that ASTs are exclusive to linter checks, but I will have to check if I can make use of them in the table check script as well.
I was just able to reproduce on a brand-new Australia PDI. Here are the specific steps to reproduce.
- Get a fresh Australia instance assigned
- Create a linter check (import the attached lintercheck.xml file)
- Run a "Test Check" from the linter check form
- Failure/Error shows up in the Results record's related list.
Thanks!
Edit:
Same error happens if I run the check via Full Instance or Scoped app "global" from a suite.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Just checking my PDI again today, I actually also see the error on the Related List. Didn't notice it before, because the Scan Check was still running (runs for more than 20 minutes here).
Not sure if it is because the Scan Check timed-out or that it is because of something basic in the script. Brainstorming on it because it is an interesting one.
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Just ran this script:
(function (engine) {
gs.info('LINTER CURRENT: ' +
engine.current.getTableName() + ' / ' +
engine.current.getUniqueValue());
})(engine);
To see from where the Scan Check is failing. Weirdly, it stops after the sys_script_client table, though guess thats a coincidence. My thought here is, that the next record being scanned, causes the error and the Scan to stop. Though which one that is, I don't know yet 😅
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field