CEL event interpreters fail to handle error conditions consistently

Description

Given some CEL event(e.g. WAZO_USER_MISSED_CALL , WAZO_MEETING_NAME , WAZO_CONFERENCE) is missing the expected extradata needed to process it correctly

Then the event interpreter method silently returns None instead of returning the input RawCallLog object

Then the next event interpreter will be passed a None value for its input call_log parameter, and will crash when accessing its attributes

Expected the contract of each event interpreter to be consistent in its return types and input types

Expected event interpreters to be consistent and outspoken about error conditions that may prevent further processing

Details

https://github.com/wazo-platform/wazo-call-logd/blob/b59227ebf9b55b710b77e52e62d437ab2194ac59/wazo_call_logd/cel_interpretor.py#L382-L384

https://github.com/wazo-platform/wazo-call-logd/blob/b59227ebf9b55b710b77e52e62d437ab2194ac59/wazo_call_logd/cel_interpretor.py#L405-L407

https://github.com/wazo-platform/wazo-call-logd/blob/b59227ebf9b55b710b77e52e62d437ab2194ac59/wazo_call_logd/cel_interpretor.py#L392-L394

These event handler methods return nothing (None ) when the cel is missing the extradata expected.

There is no exception being raised, and no logging documenting that this is an error condition.

https://github.com/wazo-platform/wazo-call-logd/blob/b59227ebf9b55b710b77e52e62d437ab2194ac59/wazo_call_logd/cel_interpretor.py#L179-L183
Since the interpret_cels method is calling each event handler with the return value of the previous one, the next event handler following each of these three handler may receive a call_log argument that is a Nonevalue, which no handler expects and deal with.

  • event handlers can be modeled as functions RawCallLog -> RawCallLog. In this model, either a handler should fail and raise, or return a valid RawCallLog value(which may be its undisturbed input)

  • AbstractCELInterpretor.interpret_cels can validate the output of each handler before passing it as input to the next handler, ensuring no handler receives invalid inputs. This is not necessary if we statically ensure each handler always return a valid RawCallLog(through type checking).

  • If those three cases of missing extra data should be considered critical, and further processing would not be worth it, then they should raise an exception and interrupt the processing of this sequence of CEL. The calling code (generator.CallLogsgenerator.call_logs_from_cel) can then expect and handle this failure

Zendesk Ticket IDs

None

Attachments

2
  • 11 Dec 2023, 07:14 PM
  • 11 Dec 2023, 07:14 PM

Activity

Show:

Charles Langlois January 16, 2025 at 8:06 PM

Associated PR already merged.

Charles Langlois December 11, 2023 at 6:50 PM
Edited

 

  • first patch address cel handlers contract violation by returning the input call log instead of nothing, also logging an error

  • second patch address robustness of overall call logs processing by handling cel interpretation errors by logging and continuing. This requires all critical cel interpretation errors to be raised as CELInterpretationError exception, which is not currently the case. A stronger approach would catch and handle all exceptions (except Exception) .

Done

Details

Priority

Assignee

Reporter

Fix versions

Zendesk Support

Created December 11, 2023 at 3:46 PM
Updated January 16, 2025 at 8:07 PM
Resolved January 16, 2025 at 8:06 PM

Flag notifications