Skip to content

Commit

Permalink
Improve the action schema.
Browse files Browse the repository at this point in the history
The new schema is functionally equivalent to the old schema
but the non-validation messages are much better.

Validating

{"action": "failed_task", "message": "It's going well!"}

against the old schema may yield (it is not deterministic)

action['worker'] is missing and action['worker'] is missing and
action['worker'] is missing and action['action']
(value:'failed_task') is not equal to 'system_event' and
action['action'] (value:'failed_task') is not equal to 'new_run'
and action['action'] (value:'failed_task') is not equal to
'upload_nn' and action['action'] (value:'failed_task') is not
equal to 'modify_run' and action['action'] (value:'failed_task')
is not equal to 'delete_run' and action['action']
(value:'failed_task') is not equal to 'stop_run' and
action['action'] (value:'failed_task') is not equal to
'finished_run' and action['action'] (value:'failed_task') is not
equal to 'approve_run' and action['action'] (value:'failed_task')
is not equal to 'purge_run' and action['user'] is missing and
action['user'] is missing and action['worker'] is missing and
action['action'] (value:'failed_task') is not equal to
'log_message'

whereas the new schema gives

action['worker'] is missing

Requires upgrading the vtjson package.
  • Loading branch information
vdbergh authored and ppigazzini committed Apr 9, 2024
1 parent b5c9729 commit 85cc51d
Show file tree
Hide file tree
Showing 2 changed files with 235 additions and 144 deletions.
6 changes: 4 additions & 2 deletions server/fishtest/actiondb.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,10 @@ def insert_action(self, **action):
action["time"] = datetime.now(timezone.utc).timestamp()
try:
validate(action_schema, action, "action")
except ValidationError:
message = f"Internal Error. Request {str(action)} does not validate"
except ValidationError as e:
message = (
f"Internal Error. Request {str(action)} does not validate: {str(e)}"
)
print(message, flush=True)
self.log_message(
username="fishtest.system",
Expand Down
Loading

0 comments on commit 85cc51d

Please sign in to comment.