Quick Tip: The First Rule of ServerLogic Delete Club
I recently came across a ServerLogic script that refused to validate, throwing this delightfully cryptic error:
Script validation failed: prohibited pattern found - Pattern: delete\s+[a-zA-Z_$] Naturally, the first thought was: "But I'm not using delete anywhere!"
Turns out I was. Just not in the way I thought.
The First Rule of ServerLogic Delete Club do not use the word "delete" anywhere in your script.
- Not in code
- Not in comments
- Not in trace statements
Not in those little notes you leave for Future You, In fact, pretend the word never existed and Use alternatives such as:
- Remove
- Record removal
- Purge
- Destroy (okay, maybe not that one)
- Make it disappear
For example:
trace("Record removal started"); // good
trace("Delete operation started"); // Not so good Decoding the mystery Regex, The validator is looking for this pattern:
delete\s+[a-zA-Z_$]
Let's translate that from Regex into English.
delete - The literal word "delete",
\s+ - One or more spaces, tabs, or line breaks
[a-zA-Z_$] - The start of a variable or identifier
So it's trying to find things like:
delete record
delete customer
delete _entity
delete $something Which makes sense because JavaScript has a
delete operator.delete customer.name; The validator appears to be checking for this potentially dangerous construct and blocking it. Validators are not always blessed with context. Sometimes they see:
// Delete customer record
or
trace("Delete operation started"); and think "Aha! Dangerous code!"
Meanwhile you're staring at the screen wondering why a logging message is being treated like a national security threat.
The fix is surprisingly simple: No delete.
Yes, that's now my official technical recommendation. Search your script for the word delete and replace it with something less offensive to the validation engine. Once the forbidden word has been banished, your script will usually validate happily and everybody can move on with their day.
If you're getting a mysterious validation error and your ServerLogic script looks perfectly innocent, don't just inspect the code. Check the comments, trace messages, and strings too. Because sometimes the problem isn't that you're deleting a record. It's that you talked about deleting a record. And apparently that's where ServerLogic draws the line.
Pro Tip: If you ever find yourself debugging this error for more than five minutes, perform a global search for the word delete. Future You will thank Present You. Or at least stop muttering at the monitor.