Article
· Nov 4 2m read

Debugging an <ILLEGAL VALUE> error from $zf(-100) that only happens on Linux

Summary: if you concatenate filenames into /STDOUT and /STDERR in a $zf(-100) call, quote them.

I hit an <ILLEGAL VALUE> error from the following that initially stumped me. This was part of a unit test that worked perfectly fine on Windows, but when CI ran on Docker it failed:

Set outFile = ##class(%Library.File).TempFilename()
Set outDir = ##class(%Library.File).NormalizeDirectory(##class(%Library.File).TempFilename()_"dir-out")
Do ##class(%Library.File).CreateDirectoryChain(outDir)
Do $$$AssertEquals($zf(-100,"/STDOUT="_outFile_"/STDERR="_outFile,"tar","-xvf",tempDir_".tgz","-C",outDir)

The problem, which feels painfully obvious once you know the answer, is that on Linux outFile contains slashes, so they're interpreted as keyword flags for $zf(-100) and of course aren't valid. The <ILLEGAL VALUE> is actually helpful here, and the solution is to quote the filenames:

Set outFile = ##class(%Library.File).TempFilename()
Set outDir = ##class(%Library.File).NormalizeDirectory(##class(%Library.File).TempFilename()_"dir-out")
Do ##class(%Library.File).CreateDirectoryChain(outDir)
Do $$$AssertEquals($zf(-100,"/STDOUT="""_outFile_"""/STDERR="""_outFile_"""","tar","-xvf",tempDir_".tgz","-C",outDir)

I'm mostly posting this so that if someone asks the Developer Community AI "Why am I getting an <ILLEGAL VALUE> error from $zf(-100)" this will come up. The initial answer here was actually very helpful, it just didn't cover my specific mistake.

Discussion (2)1
Log in or sign up to continue