Scriptforge GridControl, python, Error 91, Bug or Feature?

Hi,

i did create a simple Dialog with one grid control. When I call the example code from an embedded module it worls fine. When I move the source to a local file and change the onaction from

onAction = "vnd.sun.star.script:Module1.py$actionHandler?language=Python&location=document"

to

onAction = "vnd.sun.star.script:Module1.py$actionHandler?language=Python&location=user"

I get Error 91 with the text

Library :   ScriptForge
Service :   SF_Services
Method :    CreateScriptService


The ScriptForge library has crashed. The reason is unknown.
Maybe a bug that could be reported on
    https://bugs.documentfoundation.org/

More details : 

Location : SF_Services.CreateScriptService/169
Objektvariable nicht belegt.

And later when I close the dialog:
THE EXECUTION IS CANCELLED.

Error during invoking function data_map in module file:///home/dominik/.config/libreoffice/4/user/Scripts/python/ModuleKonto_200.py (<class 'RuntimeError'>: The execution of the method 'Execute' failed. Execution stops.
  File "/usr/lib/libreoffice/program/pythonscript.py", line 941, in invoke
    ret = self.func(*args)
  File "/home/dominik/.config/libreoffice/4/user/Scripts/python/ModuleKonto_200.py", line 334, in data_map
    dlgGrid()
    ~~~~~~~^^
  File "/home/dominik/.config/libreoffice/4/user/Scripts/python/ModuleKonto_200.py", line 313, in dlgGrid
    dlg.Execute()
    ~~~~~~~~~~~^^
  File "/usr/lib/libreoffice/program/scriptforge.py", line 2187, in Execute
    return self.ExecMethod(self.vbMethod + self.flgHardCode, 'Execute', modal)
           ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/libreoffice/program/scriptforge.py", line 641, in ExecMethod
    return self.EXEC(self.objectreference, flags, methodname, *args)
           ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/libreoffice/program/scriptforge.py", line 366, in InvokeBasicService
    raise RuntimeError("The execution of the method '" + method + "' failed. Execution stops.")
)

When I move the Dialog from the document into the standard library and call it with
dlg = CreateScriptService(“SFDialogs.Dialog”, “GlobalScope”, “Standard”, “Dialog1”)
i still get the same error?

Full Example Code:

# coding: utf-8
from __future__ import unicode_literals

from scriptforge import CreateScriptService

exc = CreateScriptService("Exception")
bas = CreateScriptService("Basic")
doc = CreateScriptService("Calc")


def debug(msg) -> None:
    #bas.MsgBox('Hello, world!')
    exc.DebugPrint('Debug Msg: ', msg) # this sends the values to the SF console
    exc.Console() # this displays the SF console
    #exc.PythonShell({**globals(), **locals()}) # this opens the APSO shell
    #sprint('Value of someVar', someVar) # the values are sent to the APSO shell

onAction = "vnd.sun.star.script:Module1.py$actionHandler?language=Python&location=document"

def actionHandler(event: None) ->None:
    #debug(__file__ + ":OnAction")
    if event == None:
        return
    try:
        dlg = CreateScriptService("DialogEvent", event)
        #debug(f"A Name: {dlg.Name} Control Type: {dlg.ControlType} Event: {event}")
        #debug(dlg.ListIndex)
        idx = doc.LastRow("Tabelle1") + 1      # Next free line
        doc.SetValue("Tabelle1.A"+str(idx), str(bas.Now()))
        doc.SetValue("Tabelle1.B"+str(idx), f"Name {dlg.Name}")
        doc.SetValue("Tabelle1.C"+str(idx), f"Control Type {dlg.ControlType}")
        doc.SetValue("Tabelle1.D"+str(idx), f"ListIndex {dlg.ListIndex}")
        doc.SetValue("Tabelle1.E"+str(idx), f"Value {dlg.Value}")
        doc.SetValue("Tabelle1.F"+str(idx), f"Value {event}")

    except Exception as e:
        debug(f"actionHandler error {e}")


def dlgGrid() -> None:
    dlg = CreateScriptService("SFDialogs.Dialog", "SF_GridCtrl.ods", "Standard", "Dialog1")
    grid = dlg.Controls("GridControl1")
    #grid.OnMousePressed = onAction
    grid.OnMouseReleased = onAction
    grid_data = (("Column A", "Column B", "Column C"),
              ("Row 1", 1, 2),
              ("Row 2", 3, 4),
              ("Row 3", 5, 6))
    alignments = "LCC"
    widths = (50, 50, 50)
    grid.SetTableData(grid_data, widths, alignments)

    dlg.Execute()
    dlg.Terminate()


g_exportedScripts = (dlgGrid,)

if __name__ == '__main__':
    pass

If it matters, i have the same behaviour on MacOS and Linux and I am using the latest LO version:
Version: 25.8.3.2 (X86_64) / LibreOffice Community
Build ID: 5ee70f9e60a556cf41458d71cbfa54885591385a
CPU threads: 32; OS: Linux 6.17; UI render: default; VCL: kf6 (cairo+wayland)
Locale: de-DE (de_DE.UTF-8); UI: de-DE
25.8.3-2.1
Calc: threaded

Thanks for any advice