Skip to content
This repository has been archived by the owner on Dec 5, 2023. It is now read-only.

Better errors for invalid payloads #40

Open
jkeifer opened this issue Jan 31, 2022 · 2 comments
Open

Better errors for invalid payloads #40

jkeifer opened this issue Jan 31, 2022 · 2 comments

Comments

@jkeifer
Copy link
Member

jkeifer commented Jan 31, 2022

If no id is specified in the input payload, then we run https://github.com/cirrus-geo/cirrus-lib/blob/main/src/cirrus/lib/process_payload.py#L154. However, if we are also using a process array for workflow chaining, the line assigning the id fails with the following traceback:

[ERROR] TypeError: list indices must be integers or slices, not str
Traceback (most recent call last):
  File "/var/task/lambda_function.py", line 60, in lambda_handler
    payloads.append(ProcessPayload(payload, update=True))
  File "/var/task/cirrus/lib/process_payload.py", line 59, in __init__
    self.update()
  File "/var/task/cirrus/lib/process_payload.py", line 155, in update
    self['id'] = f"{collections_str}/workflow-{self.process['workflow']}/{items_str}"
@jkeifer jkeifer added the bug Something isn't working label Jan 31, 2022
@jkeifer
Copy link
Member Author

jkeifer commented Jan 31, 2022

It should be pretty easy to pop the id off of the test payload for one of the workflow chaining tests to duplicate this issue and facilitate debugging.

@jkeifer
Copy link
Member Author

jkeifer commented Feb 7, 2022

The error here was caused by an invalid input payload that had an array of process definitions in the first index of the process array. While this could be considered user error with no required changes, I do think having a more descriptive errors would be helpful in two main cases:

  1. in this case we should have a specific error message stating that branching is not supported in the first step of a workflow chain
  2. in the general case of an invalid payload we should try to have an invalid payload exception (probably using the from keyword to show the specific exception text.

I don't think we can necessarily enforce the latter throughout all the code, but it could be useful in the class constructor in particular.

@jkeifer jkeifer removed the bug Something isn't working label Feb 7, 2022
@jkeifer jkeifer changed the title Payload with process array fails if no id specified Better errors for invalid payloads Feb 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant