Comment 9 for bug 2060769

Revision history for this message
Jean-Baptiste Lallement (jibel) wrote : Re: pro-client execs `apt list --installed` instead of using python3-apt - leading to utf-8 errors

I tried on noble and it doesn't fix the problem.

* Firstly the upgrade to the package in proposed doesn't work if I do not force the locale.
```
Il est n cessaire de prendre 250 ko dans les archives.
Apr s cette op ration, 12,3 ko d'espace disque suppl mentaires seront utilis s.
R ception de :1 http://archive.ubuntu.com/ubuntu noble-proposed/main amd64 ubuntu-pro-client-l10n amd64 33~24.04 [19,3 kB]
R ception de :2 http://archive.ubuntu.com/ubuntu noble-proposed/main amd64 ubuntu-pro-client amd64 33~24.04 [231 kB]
250 ko r ceptionn s en 0s (938 ko/s)
(Lecture de la base de donn es... 40702 fichiers et r pertoires d j install s.)
Pr paration du d paquetage de .../ubuntu-pro-client-l10n_33~24.04_amd64.deb ...
D paquetage de ubuntu-pro-client-l10n (33~24.04) sur (32.3~24.04) ...
Pr paration du d paquetage de .../ubuntu-pro-client_33~24.04_amd64.deb ...
Traceback (most recent call last):
  File "/usr/bin/py3clean", line 210, in <module>
    main()
  File "/usr/bin/py3clean", line 196, in main
    pfiles = set(dpf.from_package(options.package))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/share/python3/debpython/files.py", line 54, in from_package
    stdout = str(stdout, 'utf-8')
             ^^^^^^^^^^^^^^^^^^^^
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe9 in position 584: invalid continuation byte
dpkg: avertissement: le sous-processus ancien paquet ubuntu-pro-client script pre-removal a renvoy un tat de sortie d'erreur 1
```

* Secondly, once the package is installed, pro status is still failing:
```
u@drenec:~$ locale
LANG=fr_FR
LANGUAGE=
LC_CTYPE="fr_FR"
LC_NUMERIC="fr_FR"
LC_TIME="fr_FR"
LC_COLLATE="fr_FR"
LC_MONETARY="fr_FR"
LC_MESSAGES="fr_FR"
LC_PAPER="fr_FR"
LC_NAME="fr_FR"
LC_ADDRESS="fr_FR"
LC_TELEPHONE="fr_FR"
LC_MEASUREMENT="fr_FR"
LC_IDENTIFICATION="fr_FR"
LC_ALL=
u@drenec:~$ apt policy ubuntu-pro-client
ubuntu-pro-client:
  Install�: 33~24.04
  Candidat�: 33~24.04
 Table de version�:
 *** 33~24.04 100
        100 http://archive.ubuntu.com/ubuntu noble-proposed/main amd64 Packages
        100 /var/lib/dpkg/status
     32.3.1~24.04 500
        500 http://archive.ubuntu.com/ubuntu noble-updates/main amd64 Packages
     31.2.3 500
        500 http://archive.ubuntu.com/ubuntu noble/main amd64 Packages
u@drenec:~$ pro status
An unexpected error occurred: 'utf-8' codec can't decode byte 0xa0 in position 18: invalid start byte
For more details, see the log: /home/u/.cache/ubuntu-pro/ubuntu-pro.log
If you think this is a bug, please run: ubuntu-bug ubuntu-advantage-tools
```

From the log the error is:
```
["2024-07-10T12:14:41.978", "ERROR", "ubuntupro.cli", "wrapper", 1360, "Unhandled exception, please file a bug", {"exc_info": "Traceback (most recent call last):\n File \"/usr/lib/python3/dist-packages/uaclient/cli/__init__.py\", line 1297, in wrapper\n return func(*args, **kwargs)\n ^^^^^^^^^^^^^^^^^^^^^\n File \"/usr/lib/python3/dist-packages/uaclient/cli/__init__.py\", line 1434, in main\n return_value = args.action(args, cfg=cfg, extra_args=extra_args)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/usr/lib/python3/dist-packages/uaclient/cli/__init__.py\", line 1104, in action_status\n status_dict, ret = actions.status(\n ^^^^^^^^^^^^^^^\n File \"/usr/lib/python3/dist-packages/uaclient/actions.py\", line 292, in status\n status = ua_status.status(cfg=cfg, show_all=show_all)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/usr/lib/python3/dist-packages/uaclient/status.py\", line 384, in status\n response = _attached_status(cfg)\n ^^^^^^^^^^^^^^^^^^^^^\n File \"/usr/lib/python3/dist-packages/uaclient/status.py\", line 271, in _attached_status\n _attached_service_status(ent, inapplicable_resources, cfg)\n File \"/usr/lib/python3/dist-packages/uaclient/status.py\", line 172, in _attached_service_status\n ent_status, details = ent.user_facing_status()\n ^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/usr/lib/python3/dist-packages/uaclient/entitlements/base.py\", line 1161, in user_facing_status\n application_status, explanation = self.application_status()\n ^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/usr/lib/python3/dist-packages/uaclient/entitlements/repo.py\", line 385, in application_status\n policy = apt.get_apt_cache_policy(error_msg=messages.APT_POLICY_FAILED)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/usr/lib/python3/dist-packages/uaclient/apt.py\", line 254, in get_apt_cache_policy\n return run_apt_command(\n ^^^^^^^^^^^^^^^^\n File \"/usr/lib/python3/dist-packages/uaclient/apt.py\", line 223, in run_apt_command\n out, _err = system.subp(\n ^^^^^^^^^^^^\n File \"/usr/lib/python3/dist-packages/uaclient/system.py\", line 721, in subp\n out, err = _subp(\n ^^^^^^\n File \"/usr/lib/python3/dist-packages/uaclient/system.py\", line 667, in _subp\n out_result = out.decode(\"utf-8\") if out else \"\"\n ^^^^^^^^^^^^^^^^^^^\nUnicodeDecodeError: 'utf-8' codec can't decode byte 0xa0 in position 18: invalid start byte"}]
```

full log attached

Marking as verification-failed