types: add missing enumerations values for TaskStatus

In a bug report, Subiquity failed during a refresh because it received
an unexpected status.

  File "subiquity/common/api/server.py", line 164, in handler
    result = await implementation(**args)
  File "subiquity/server/controllers/refresh.py", line 240, in progress_GET
    return await self.get_progress(change_id)
  File "subiquity/server/controllers/refresh.py", line 224, in get_progress
    change = await self.app.snapdapi.v2.changes[change_id].GET()
  [...]
  File "subiquity/common/serialize.py", line 252, in _deserialize_attr
    args[field.name] = self._deserialize(
  File "subiquity/common/serialize.py", line 277, in _deserialize
    return self._deserialize_enum(annotation, context)
  File "subiquity/common/serialize.py", line 261, in _deserialize_enum
    return annotation(context.cur)
  File "/usr/lib/python3.10/enum.py", line 385, in __call__
    return cls.__new__(cls, value)
  File "usr/lib/python3.10/enum.py", line 710, in __new__
    raise ve_exc
ValueError: 'Undone' is not a valid TaskStatus

According to snapd's upstream repository, "Undone" existed before
"Undoing", so I'm not sure why we didn't have the former but had the
latter. Maybe we just overlooked it because the name is similar.

As for more recently, the "Wait" status was also introduced.

Fixed by adding the two missing values (i.e., "Wait" and "Undone").

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
This commit is contained in:
Olivier Gayot 2024-04-25 15:13:55 +02:00
parent 26bc08b694
commit 00c09a9356
1 changed files with 2 additions and 0 deletions

View File

@ -819,9 +819,11 @@ class TaskStatus(enum.Enum):
DO = "Do" DO = "Do"
DOING = "Doing" DOING = "Doing"
DONE = "Done" DONE = "Done"
WAIT = "Wait"
ABORT = "Abort" ABORT = "Abort"
UNDO = "Undo" UNDO = "Undo"
UNDOING = "Undoing" UNDOING = "Undoing"
UNDONE = "Undone"
HOLD = "Hold" HOLD = "Hold"
ERROR = "Error" ERROR = "Error"