Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

types: add missing enumerations values for TaskStatus #1980

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ogayot
Copy link
Member

@ogayot ogayot commented Apr 25, 2024

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 [1]

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

[1] snapcore/snapd@7734ffd

This relates to LP:#2062512 (sorry private report)

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>
@ogayot ogayot requested a review from mwhudson April 25, 2024 13:26
@mwhudson
Copy link
Collaborator

This is one of the pain points of using the style of serialization for enums subiquity uses for an API we do not 100% control. Maybe there should be a way to say that a field can be an enum but if the value seen does not match one of the values of the enum type, just include it as a string or something?

Copy link
Collaborator

@mwhudson mwhudson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That said, this is clearly ok

@mwhudson
Copy link
Collaborator

That said again... what should subiquity do in the case that it sees an Undone change? That's probably a terminal status, right?

@ogayot
Copy link
Member Author

ogayot commented Apr 26, 2024

That said again... what should subiquity do in the case that it sees an Undone change? That's probably a terminal status, right?

Good question, I have to check what the Undoing / Undone logic means in the snap refresh context..

@@ -819,9 +819,11 @@ class TaskStatus(enum.Enum):
DO = "Do"
DOING = "Doing"
DONE = "Done"
WAIT = "Wait"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might as well also add Default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants