Just some minor stuff:

1) Don't overwrite the message of all Workflow Task Exceptions to say "Something went wrong"
2) log errors when correlation evaluations fail (just so we are aware something isn't working correctly)
3) Dont make all evaluation fuctions require a current task context to execute -- that should be optional.
This commit is contained in:
Dan 2023-03-06 17:07:04 -05:00
parent b30ed8f3c1
commit bc225fcea8
3 changed files with 15 additions and 13 deletions

View File

@ -149,7 +149,7 @@ class ApiError(Exception):
# Note that WorkflowDataExceptions are also WorkflowTaskExceptions
return ApiError.from_task(
error_code,
message,
message + ". " + str(exp),
exp.task,
line_number=exp.line_number,
offset=exp.offset,

View File

@ -6,6 +6,7 @@ from typing import Optional
from typing import TYPE_CHECKING
from SpiffWorkflow.bpmn.PythonScriptEngine import PythonScriptEngine # type: ignore
from flask import current_app
from sqlalchemy import ForeignKey
from sqlalchemy.event import listens_for
from sqlalchemy.orm import relationship
@ -135,10 +136,15 @@ class MessageInstanceModel(SpiffworkflowBaseDBModel):
result = expression_engine._evaluate(
correlation_key.retrieval_expression, payload
)
except Exception:
except Exception as e:
# the failure of a payload evaluation may not mean that matches for these
# message instances can't happen with other messages. So don't error up.
# fixme: Perhaps log some sort of error.
current_app.logger.warning(
"Error evaluating correlation key when comparing send and receive messages." +
f"Expression {correlation_key.retrieval_expression} failed with the error " +
str(e)
)
return False
if result != expected_value:
return False

View File

@ -318,18 +318,14 @@ class CustomBpmnScriptEngine(PythonScriptEngine): # type: ignore
def __get_augment_methods(self, task: Optional[SpiffTask]) -> Dict[str, Callable]:
"""__get_augment_methods."""
tld = current_app.config["THREAD_LOCAL_DATA"]
tld = current_app.config.get("THREAD_LOCAL_DATA")
if not hasattr(tld, "process_model_identifier"):
raise MissingProcessInfoError(
"Could not find process_model_identifier from app config"
)
if not hasattr(tld, "process_instance_id"):
raise MissingProcessInfoError(
"Could not find process_instance_id from app config"
)
process_model_identifier = None
else:
process_model_identifier = tld.process_model_identifier
if not hasattr(tld, "process_instance_id"):
process_instance_id = None
else:
process_instance_id = tld.process_instance_id
script_attributes_context = ScriptAttributesContext(
task=task,