I know this is old and doesn't quite apply to your situation, but you can also get this error if you use the File Name setting: %f. I ran into an issue where the DTL 'copy' function wasn't working so the Ens.StreamContainer's OriginalFilename property wasn't copied and it would give this error because the File Name was blank/null.

The solution wound up being to create a new %Stream.GlobalCharacter Stream, read from the source object stream and write the replaced string to this stream, and finally set it to the Ens.StreamContainer target object.

I still have no idea why creating a new stream works while re-writing the existing stream doesn't. The docs seem to imply it should work and even saving the stream after writing didn't do anything different. In Message Viewer, I can see its creating a new body object, as well. Creating a new Stream object works, so I guess that's fine.

According to the doc, that doesn't seem to be the case, see reference below. Since I'm not reading the stream, it should start at byte 0 then overwrite the existing data. But, since the new data is smaller than the original, I would assume I should have duplicate data at the end. For w/e reason, I don't.

But this is kind of off topic as this isn't really my issue; the data looks correct. I'm trying to figure out why it works on the DTL testing tool, but doesn't while running in the actual Process.

Commonly Used Stream Methods and Properties

"Write() — Append data to the stream, starting at the current position. Overwrites existing data if the position is not set to the end of the stream."

I think the problem is that it is not re-compiling after change, because the code doesn't change. Below is what I get when changing a comment.

Compilation started on 10/05/2022 11:37:01 with qualifiers 'cuk'
Class Custom.Utility.Functions is up-to-date.
Compilation finished successfully in 0.002s.

FYI, its not an issue for me anymore. I've been adding a space or something in the code to force a re-compile and it works. Mostly just annoying.

1:     ^IRIS.Temp.Atelier("debug")    =    1
2:     ^IRIS.Temp.Atelier("debug",127434)    =    1
3:     ^IRIS.Temp.Atelier("debug",127434,1,0)    =    42
4:     ^IRIS.Temp.Atelier("debug",127434,1,1)    =    "Event:init|<init appid=""AtelierDebugger""      idekey=""Atelier""      session=""127434""      thread=""1""      parent=""IRIS for UNIX (Red Hat Enterprise Linux for x86-64) 2021.1 (Build 215U) Wed Jun 9 2021 09:48:12 EDT""      language=""COS""      protocol_version=""1.0""      fileuri=""file://"">    <engine version=""1.0"">%Atelier.XDebugAgent</engine>    <company>InterSystems Corporation</company>    <license>Copyright 2015 InterSystems Corporation</license>    <url>http://www.intersystems.com</url>    <copyright>Copyright 2015 InterSystems Corporation</copyright></init>"
5:     ^IRIS.Temp.Atelier("debug",127434,1,2)    =    "Received:feature_set -i 1 -n max_data -v 8192"
6:     ^IRIS.Temp.Atelier("debug",127434,1,3)    =    "Calling state feature_set"
7:     ^IRIS.Temp.Atelier("debug",127434,1,4)    =    "Event:feature_set|<response command='feature_set' feature='max_data' success='1' transaction_id='1'/>"
8:     ^IRIS.Temp.Atelier("debug",127434,1,5)    =    "Received:feature_set -i 2 -n max_children -v 32"
9:     ^IRIS.Temp.Atelier("debug",127434,1,6)    =    "Calling state feature_set"
10:     ^IRIS.Temp.Atelier("debug",127434,1,7)    =    "Event:feature_set|<response command='feature_set' feature='max_children' success='1' transaction_id='2'/>"
11:     ^IRIS.Temp.Atelier("debug",127434,1,8)    =    "Received:feature_set -i 3 -n max_depth -v 2"
12:     ^IRIS.Temp.Atelier("debug",127434,1,9)    =    "Calling state feature_set"
13:     ^IRIS.Temp.Atelier("debug",127434,1,10)    =    "Event:feature_set|<response command='feature_set' feature='max_depth' success='1' transaction_id='3'/>"
14:     ^IRIS.Temp.Atelier("debug",127434,1,11)    =    "Received:feature_set -i 4 -n notify_ok -v 1"
15:     ^IRIS.Temp.Atelier("debug",127434,1,12)    =    "Calling state feature_set"
16:     ^IRIS.Temp.Atelier("debug",127434,1,13)    =    "Event:feature_set|<response command='feature_set' feature='notify_ok' success='1' transaction_id='4'/>"
17:     ^IRIS.Temp.Atelier("debug",127434,1,14)    =    "Received:feature_set -i 5 -n debug_target -v_base64 VlVNQ1BSSU1BUlk6IyNjbGFzcyhWVU1DLlV0aWxpdHkuQ2VybmVyTGFiRnVuY3Rpb25zKS5WVU1DU2VsZWN0UGVyZm9ybWluZ0xhYkFyZWEoIk9SRDAwMDAzMTQiLCJFRFAiLCJTVCIp"
18:     ^IRIS.Temp.Atelier("debug",127434,1,15)    =    "Calling state feature_set"
19:     ^IRIS.Temp.Atelier("debug",127434,1,16)    =    "Launching: ##class(Custom.Utility.Functions).SelectArea(""arg1"",""arg2"",""arg3"")"
20:     ^IRIS.Temp.Atelier("debug",127434,1,17)    =    "PID 130498"
21:     ^IRIS.Temp.Atelier("debug",127434,1,18)    =    "Debug Device Name:|TCP|34811"
22:     ^IRIS.Temp.Atelier("debug",127434,1,19)    =    "Event:feature_set|<response command='feature_set' feature='debug_target' success='1' transaction_id='5'/>"
23:     ^IRIS.Temp.Atelier("debug",127434,1,20)    =    "Received:breakpoint_list -i 6"
24:     ^IRIS.Temp.Atelier("debug",127434,1,21)    =    "Calling state breakpoint_list"
25:     ^IRIS.Temp.Atelier("debug",127434,1,22)    =    "Event:breakpoint_list|<response command='breakpoint_list' transaction_id='6'></response>"
26:     ^IRIS.Temp.Atelier("debug",127434,1,23)    =    "Received:breakpoint_set -i 7 -t line -s enabled -f dbgp://|PRIMARY|Custom.Utility.Functions.cls -m SelectArea -n 1"
27:     ^IRIS.Temp.Atelier("debug",127434,1,24)    =    "Calling state breakpoint_set"
28:     ^IRIS.Temp.Atelier("debug",127434,1,25)    =    "mapping: PRIMARY:Custom.Utility.Functions.cls:SelectArea:1 -> :-1"
29:     ^IRIS.Temp.Atelier("debug",127434,1,26)    =    "Event:error|<response command='breakpoint_set' transaction_id='7'><error code='201'><message>Breakpoint Cannot Be Mapped</message></error></response>"
30:     ^IRIS.Temp.Atelier("debug",127434,1,27)    =    "Received:breakpoint_list -i 8"
31:     ^IRIS.Temp.Atelier("debug",127434,1,28)    =    "Calling state breakpoint_list"
32:     ^IRIS.Temp.Atelier("debug",127434,1,29)    =    "Event:breakpoint_list|<response command='breakpoint_list' transaction_id='8'></response>"
33:     ^IRIS.Temp.Atelier("debug",127434,1,30)    =    "Received:run -i 9"
34:     ^IRIS.Temp.Atelier("debug",127434,1,31)    =    "Calling state run"
35:     ^IRIS.Temp.Atelier("debug",127434,1,32)    =    "IsStopped"
36:     ^IRIS.Temp.Atelier("debug",127434,1,33)    =    "Location zDebugStub+40:%Debugger.System.1:0:0:0:0:6:0:0:0:0:0:PRIMARY"
37:     ^IRIS.Temp.Atelier("debug",127434,1,34)    =    "Stack 3^zDebugStub+40^%Debugger.System.1"
38:     ^IRIS.Temp.Atelier("debug",127434,1,35)    =    "Ran Off End"
39:     ^IRIS.Temp.Atelier("debug",127434,1,36)    =    "FlushOut"
40:     ^IRIS.Temp.Atelier("debug",127434,1,37)    =    "Timed out"
41:     ^IRIS.Temp.Atelier("debug",127434,1,38)    =    "IsStopped"
42:     ^IRIS.Temp.Atelier("debug",127434,1,39)    =    "Event:stop|<response command='run' status='stopped' reason='ok' transaction_id='9'/>"
43:     ^IRIS.Temp.Atelier("debug",127434,1,40)    =    "TidyUp: 1"
44:     ^IRIS.Temp.Atelier("debug",127434,1,41)    =    "Exiting"
45:     ^IRIS.Temp.Atelier("debug",127434,1,42)    =    "OnClose"