You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: Short-circuit evaluation bug in TaskManager #235
When self.context_id is falsy (None, empty string, etc.), then thenot clause for self.context_id evaluates to True
Due to short-circuit evaluation care of and, Python never evaluates the second part: self.context_id != event.contextId
The condition becomes ~~ True and = True. ~~
The code sets self.context_id = event.contextId (which is correct behavior), ok so far.
When self.context_id has a value:
the not in self.context_id evaluates to False
Due to short-circuit evaluation, the entire condition becomes False
So context ID validation self.context_id != event.contextId never runs
So the current code will never detect mismatched context IDs because the validation check part is unreachable when self.context_id already has a value. Like I say though I might be wrong and forgive wasting time if so.
I think something like this should do the job:
if not self.task_id:
self.task_id = task_id_from_event
- if not self.context_id and self.context_id != event.contextId:
+ if self.context_id and self.context_id != event.contextId:
+ raise ServerError(
+ error=InvalidParamsError(
+ message=f"Context in event doesn't match TaskManager: {self.context_id} : {event.contextId}"
+ )
+ )
+ if not self.context_id:
self.context_id = event.contextId
Activity
fix: Fixes Short Circuit clause for context ID (#236)
fix: Fixes Short Circuit clause for context ID (#236)