sartography / spiff-arena

SpiffWorkflow is a software development platform for building, running, and monitoring executable diagrams
https://www.spiffworkflow.org/
GNU Lesser General Public License v2.1
49 stars 36 forks source link

Refresh permissions not working #1433

Open stefanroels opened 2 months ago

stefanroels commented 2 months ago

Hello,

I am trying to setup the permissions on my SpiffArena instance, but I get the following message when I run refresh_permissions:

image

The code I use is:

refresh_permissions(group_info,group_permissions_only=True)
all_permissions = get_all_permissions()

I have tried without the group_permissions_only=True, but with no differences.

I am running the a7a9927a5f547aaf1ea8ec47ff0b31479f25b684 version of SpiffArena.

burnettk commented 1 month ago

@stefanroels did you ever get this sorted out?

stefanroels commented 2 weeks ago

Sorry for my late reaction. I have just tried again with the eae5f7d version and I still have the problem.

I had a look at the log file of the backend container and that showed the following:

ERROR ProcessInstanceNotFoundError:Could not find a process instance with id 'None' when running script 'refresh_permissions'. .  | loggerName=spiffworkflow_backend processName=MainProcess processID=47 threadName=ThreadPoolExecutor-1_1 threadID=140274817074880 timestamp=2024-06-10T17:12:00.341Z exc_info=Traceback (most recent call last):
  File "/app/venv/lib/python3.12/site-packages/SpiffWorkflow/bpmn/script_engine/python_engine.py", line 63, in execute
    return self.environment.execute(script, task.data, external_context or {})
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/src/spiffworkflow_backend/services/process_instance_processor.py", line 177, in execute
    super().execute(script, context, external_context)
  File "/app/venv/lib/python3.12/site-packages/SpiffWorkflow/bpmn/script_engine/python_environment.py", line 53, in execute
    exec(script, context)
  File "<string>", line 1, in <module>
  File "/app/src/spiffworkflow_backend/scripts/script.py", line 133, in run_script_if_allowed
    check_script_permission()
  File "/app/src/spiffworkflow_backend/scripts/script.py", line 120, in check_script_permission
    raise ProcessInstanceNotFoundError(
spiffworkflow_backend.models.process_instance.ProcessInstanceNotFoundError: Could not find a process instance with id 'None' when running script 'refresh_permissions'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/app/src/spiffworkflow_backend/services/workflow_execution_service.py", line 454, in run_and_save
    task_runnability = self.execution_strategy.spiff_run(
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/src/spiffworkflow_backend/services/workflow_execution_service.py", line 163, in spiff_run
    self._run_engine_steps_with_threads(engine_steps, process_instance_model, user)
  File "/app/src/spiffworkflow_backend/services/workflow_execution_service.py", line 205, in _run_engine_steps_with_threads
    spiff_task = future.result()
                 ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/_base.py", line 449, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/src/spiffworkflow_backend/services/workflow_execution_service.py", line 124, in _run
    spiff_task.run()
  File "/app/venv/lib/python3.12/site-packages/SpiffWorkflow/task.py", line 349, in run
    retval = self.task_spec._run(self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/venv/lib/python3.12/site-packages/SpiffWorkflow/specs/base.py", line 321, in _run
    raise exc
  File "/app/venv/lib/python3.12/site-packages/SpiffWorkflow/specs/base.py", line 314, in _run
    result = self._run_hook(my_task)
             ^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/venv/lib/python3.12/site-packages/SpiffWorkflow/bpmn/specs/mixins/script_task.py", line 31, in _run_hook
    return self._execute(task)
           ^^^^^^^^^^^^^^^^^^^
  File "/app/venv/lib/python3.12/site-packages/SpiffWorkflow/bpmn/specs/mixins/script_task.py", line 46, in _execute
    return task.workflow.script_engine.execute(task, self.script)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/src/spiffworkflow_backend/services/process_instance_processor.py", line 389, in execute
    raise e
  File "/app/src/spiffworkflow_backend/services/process_instance_processor.py", line 386, in execute
    super().execute(task, script, methods)
  File "/app/venv/lib/python3.12/site-packages/SpiffWorkflow/bpmn/script_engine/python_engine.py", line 66, in execute
    raise wte
SpiffWorkflow.bpmn.exceptions.WorkflowTaskException: ProcessInstanceNotFoundError:Could not find a process instance with id 'None' when running script 'refresh_permissions'. 

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/app/venv/lib/python3.12/site-packages/flask/app.py", line 1823, in full_dispatch_request
    rv = self.dispatch_request()
         ^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/venv/lib/python3.12/site-packages/flask/app.py", line 1799, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/venv/lib/python3.12/site-packages/connexion/decorators/decorator.py", line 68, in wrapper
    response = function(request)
               ^^^^^^^^^^^^^^^^^
  File "/app/venv/lib/python3.12/site-packages/connexion/decorators/uri_parsing.py", line 149, in wrapper
    response = function(request)
               ^^^^^^^^^^^^^^^^^
  File "/app/venv/lib/python3.12/site-packages/connexion/decorators/validation.py", line 196, in wrapper
    response = function(request)
               ^^^^^^^^^^^^^^^^^
  File "/app/venv/lib/python3.12/site-packages/connexion/decorators/validation.py", line 399, in wrapper
    return function(request)
           ^^^^^^^^^^^^^^^^^
  File "/app/venv/lib/python3.12/site-packages/connexion/decorators/parameter.py", line 120, in wrapper
    return function(**kwargs)
           ^^^^^^^^^^^^^^^^^^
  File "/app/src/spiffworkflow_backend/routes/tasks_controller.py", line 439, in task_submit
    response_item = _task_submit_shared(process_instance_id, task_guid, body, execution_mode=execution_mode)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/src/spiffworkflow_backend/routes/process_api_blueprint.py", line 542, in _task_submit_shared
    ProcessInstanceService.complete_form_task(
  File "/app/src/spiffworkflow_backend/services/process_instance_service.py", line 495, in complete_form_task
    processor.do_engine_steps(save=True, execution_strategy_name=execution_strategy_name)
  File "/app/src/spiffworkflow_backend/services/process_instance_processor.py", line 1436, in do_engine_steps
    return self._do_engine_steps(exit_at, save, execution_strategy_name, execution_strategy)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/src/spiffworkflow_backend/services/process_instance_processor.py", line 1480, in _do_engine_steps
    task_runnability = execution_service.run_and_save(exit_at, save)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/src/spiffworkflow_backend/services/workflow_execution_service.py", line 473, in run_and_save
    raise WorkflowExecutionServiceError.from_workflow_task_exception(wte) from wte
spiffworkflow_backend.services.workflow_execution_service.WorkflowExecutionServiceError: ProcessInstanceNotFoundError:Could not find a process instance with id 'None' when running script 'refresh_permissions'. .  
burnettk commented 1 week ago

Do you have a process model you would be able to zip up that repros?