Fix that dreadful unknown "KeyError" exception that was cropping up.

Adding a bit of detail to the spiffworkflow exceptions when a duplicate process model is found.
Disable the submit button on tasks after you click submit (avoid the double click and give users a better experience)
This commit is contained in:
Dan 2023-02-03 17:01:03 -05:00
parent 80649382f9
commit 86b248faf3
3 changed files with 15 additions and 6 deletions

View File

@ -242,6 +242,10 @@ def handle_exception(exception: Exception) -> flask.wrappers.Response:
api_exception = None
if isinstance(exception, ApiError):
api_exception = exception
elif isinstance(exception, SpiffWorkflowException):
api_exception = ApiError.from_workflow_exception(
"unexpected_workflow_exception", "Unexpected Workflow Error", exception
)
else:
api_exception = ApiError(
error_code=error_code,

View File

@ -275,7 +275,7 @@ def task_show(process_instance_id: int, task_id: str) -> flask.wrappers.Response
) from exception
if task.data:
_update_form_schema_with_task_data_as_needed(form_dict, task)
_update_form_schema_with_task_data_as_needed(form_dict, task, spiff_task)
if form_contents:
task.form_schema = form_dict
@ -588,7 +588,9 @@ def _get_spiff_task_from_process_instance(
# originally from: https://bitcoden.com/answers/python-nested-dictionary-update-value-where-any-nested-key-matches
def _update_form_schema_with_task_data_as_needed(in_dict: dict, task: Task) -> None:
def _update_form_schema_with_task_data_as_needed(
in_dict: dict, task: Task, spiff_task: SpiffTask
) -> None:
"""Update_nested."""
if task.data is None:
return None
@ -615,7 +617,7 @@ def _update_form_schema_with_task_data_as_needed(in_dict: dict, task: Task) -> N
f" '{task_data_var}' but it doesn't exist in"
" the Task Data."
),
task=task,
task=spiff_task,
)
raise (
ApiError.from_workflow_exception(
@ -648,11 +650,11 @@ def _update_form_schema_with_task_data_as_needed(in_dict: dict, task: Task) -> N
in_dict[k] = options_for_react_json_schema_form
elif isinstance(value, dict):
_update_form_schema_with_task_data_as_needed(value, task)
_update_form_schema_with_task_data_as_needed(value, task, spiff_task)
elif isinstance(value, list):
for o in value:
if isinstance(o, dict):
_update_form_schema_with_task_data_as_needed(o, task)
_update_form_schema_with_task_data_as_needed(o, task, spiff_task)
def _get_potential_owner_usernames(assigned_user: AliasedClass) -> Any:

View File

@ -499,7 +499,10 @@ class ProcessModelService(FileSystemService):
if name is None:
raise ApiError(
error_code="missing_name_of_process_model",
message="Missing name of process model. It should be given",
message=(
"Missing name of process model. Path not found:"
f" {json_file_path}"
),
)
process_model_info = ProcessModelInfo(