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

ykman config nfc [OPTION] on Non-NFC YubiKey 5 series raise not human-readable errors #542

Closed
solzard opened this issue Feb 14, 2023 · 2 comments
Labels

Comments

@solzard
Copy link

solzard commented Feb 14, 2023

  • YubiKey Manager (ykman) version: 5.0.1

  • How was it installed?: brew install ykman

  • Operating system and version: ProductName:

    • macOS
    • ProductVersion: 12.6.3
    • BuildVersion: 21G419
    • Apple M1 Pro
  • YubiKey model and version:

    • YubiKey 5C (5.4.3)
    • YubiKey 5C Nano (5.4.3)
  • Bug description summary:
    Non-NFC Yubikey 5 series raise a raw Python traceback instead of a human-readable error message when running ykman config nfc [OPTION].

Steps to reproduce

Run one of the following command with YubiKey 5C (5.4.3) or YubiKey 5C Nano (5.4.3)

  • ykman config nfc --list
  • ykman config nfc --enable-all
  • ykman config nfc --disable-all

Expected result

Show a human-readable error message that NFC is not available with the key such as YubiKey 4 (4.3.5) returns:

❯ ykman list
YubiKey 4 (4.3.5) [OTP+FIDO+CCID] Serial: XXXXXXX

❯ ykman config nfc --list
ERROR: Configuring applications is not supported on this YubiKey. Use the `mode` command to configure USB interfaces

Or, some kind of

  • ERROR: NFC is not supported on this YubiKey.

Actual results and logs

Both ykman config nfc --list and ykman config nfc [--enable-all / --disable-all] raise the same TypeError: unsupported operand type(s) for &: 'NoneType' and 'CAPABILITY'; however, the raised lines are different:

❯ ykman list
YubiKey 5C Nano (5.4.3) [OTP+FIDO+CCID] Serial: XXXXXXX

❯ ykman config nfc --list
ERROR: An unexpected error has occuredTraceback (most recent call last):
  File "/opt/homebrew/Cellar/ykman/5.0.1/libexec/lib/python3.11/site-packages/ykman/_cli/__main__.py", line 364, in main
    cli(obj={})
  File "/opt/homebrew/Cellar/ykman/5.0.1/libexec/lib/python3.11/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/ykman/5.0.1/libexec/lib/python3.11/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/ykman/5.0.1/libexec/lib/python3.11/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/ykman/5.0.1/libexec/lib/python3.11/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/ykman/5.0.1/libexec/lib/python3.11/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/ykman/5.0.1/libexec/lib/python3.11/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/ykman/5.0.1/libexec/lib/python3.11/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/ykman/5.0.1/libexec/lib/python3.11/site-packages/ykman/_cli/config.py", line 429, in nfc
    _list_apps(ctx, TRANSPORT.NFC)
  File "/opt/homebrew/Cellar/ykman/5.0.1/libexec/lib/python3.11/site-packages/ykman/_cli/config.py", line 459, in _list_apps
    if app & enabled:
       ~~~~^~~~~~~~~
TypeError: unsupported operand type(s) for &: 'CAPABILITY' and 'NoneType'
❯ ykman config nfc --enable-all
ERROR: An unexpected error has occuredTraceback (most recent call last):
  File "/opt/homebrew/Cellar/ykman/5.0.1/libexec/lib/python3.11/site-packages/ykman/_cli/__main__.py", line 364, in main
    cli(obj={})
  File "/opt/homebrew/Cellar/ykman/5.0.1/libexec/lib/python3.11/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/ykman/5.0.1/libexec/lib/python3.11/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/ykman/5.0.1/libexec/lib/python3.11/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/ykman/5.0.1/libexec/lib/python3.11/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/ykman/5.0.1/libexec/lib/python3.11/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/ykman/5.0.1/libexec/lib/python3.11/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/ykman/5.0.1/libexec/lib/python3.11/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/ykman/5.0.1/libexec/lib/python3.11/site-packages/ykman/_cli/config.py", line 444, in nfc
    _configure_applications(
  File "/opt/homebrew/Cellar/ykman/5.0.1/libexec/lib/python3.11/site-packages/ykman/_cli/config.py", line 207, in _configure_applications
    if enable & disable:
       ~~~~~~~^~~~~~~~~
TypeError: unsupported operand type(s) for &: 'NoneType' and 'CAPABILITY'
@dainnilsson
Copy link
Member

Confirmed, this needs to be fixed.

@dainnilsson
Copy link
Member

This is now fixed and released in 5.1.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants