Merge ~nteodosio/software-properties:update-state-after-token-none into software-properties:ubuntu/master

Proposed by Nathan Teodosio
Status: Rejected
Rejected by: Sebastien Bacher
Proposed branch: ~nteodosio/software-properties:update-state-after-token-none
Merge into: software-properties:ubuntu/master
Diff against target: 17 lines (+4/-0)
1 file modified
softwareproperties/gtk/DialogUaAttach.py (+4/-0)
Reviewer Review Type Date Requested Status
Sebastien Bacher Disapprove
Review via email: mp+437143@code.launchpad.net

Description of the change

Immediately call update_state after setting contract_token = None.

To post a comment you must log in.
Revision history for this message
Nathan Teodosio (nteodosio) wrote :

attach function chooses token according to

        if self.token_radio.get_active():
            token = self.token_field.get_text()
        else:
            token = self.contract_token

The first case will always return a string, which will therefore not raise "TypeError: Expected a string or unicode object."

So the problem must be self.contract_token being None but "confirm" button being active, as per the traceback[1].

Ubuntu Advantage Client's wait() is guaranteed to return a non None, string value[2].

So the issue must be in the delayed call to update_state after setting contract_token to None in start_magic_attach.

[1] https://errors.ubuntu.com/problem/ad46a4f47c7f151d8719cb12227f57011b622f37
[2] https://github.com/canonical/ubuntu-advantage-client/blob/df9c1309bd7542007e182fa85bdd0c14b7babe98/uaclient/api/u/pro/attach/magic/wait/v1.py#L95

Revision history for this message
Sebastien Bacher (seb128) wrote :

Thanks, let's try that

Revision history for this message
Sebastien Bacher (seb128) wrote :

in fact it needs to be adapted since the code seems to have changed, could you rebase and adapt?

review: Needs Fixing
Revision history for this message
Nathan Teodosio (nteodosio) wrote :

I'm really not convinced about my original proposal.

I to get a better chance of understanding what's going on we need to narrow down where the problem occurs. At any rate a better error message.

This wouldn't really constitute a direct attempt to solve the bug though.

Revision history for this message
Sebastien Bacher (seb128) wrote :

Right. The number of reports has been very low so it's not an important issue nor a priority. I agree the current changeset is hackish and not a proper fix. Let reject that solution and probably put that on the side for now since we have higher priority items

review: Disapprove

Unmerged commits

5c54a09... by Nathan Teodosio

Throw a more detailed error if token is not string.

https://launchpad.net/bugs/2006931 reports that
self.ua_object.Attach(token, ...) ultimately raises
TypeError: Expected a string or unicode object.

This could be caused by a invalid response from wait().
Alternatively, the user could input some random bytes
in the text field, but get_text() is supposed to return gchar*
so this is unlikely to be the source of the problem.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/softwareproperties/gtk/DialogUaAttach.py b/softwareproperties/gtk/DialogUaAttach.py
2index d029e64..be8517f 100644
3--- a/softwareproperties/gtk/DialogUaAttach.py
4+++ b/softwareproperties/gtk/DialogUaAttach.py
5@@ -112,8 +112,12 @@ class DialogUaAttach:
6
7 if self.token_radio.get_active():
8 token = self.token_field.get_text()
9+ if isinstance(token, str):
10+ raise TypeError(f"Typed in token >{token}< is {type(token)}, expected str.")
11 else:
12 token = self.contract_token
13+ if isinstance(token, str):
14+ raise TypeError(f"Token >{token}< received from server is {type(token)}, expected str.")
15
16 self.attaching = True
17 def on_reply():

Subscribers

People subscribed via source and target branches