AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Informational 20 Bitcoin

fix(python): fix `trezorctl get-session` for legacy

Public commit record

What the developer wrote

Authored by Roman Zeyde

85/100 · Strong
fix(python): fix `trezorctl get-session` for legacy

`TrezorConnection._version` wasn't set, so the command was failing with:
```
Traceback (most recent call last):
File "./venv/bin/trezorctl", line 8, in <module>
sys.exit(cli())
^^^^^
File "./venv/lib/python3.12/site-packages/click/core.py", line 1161, in __call__
return self.main(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "./venv/lib/python3.12/site-packages/click/core.py", line 1082, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "/home/rzeyde/src/trezor-firmware/python/src/trezorlib/cli/trezorctl.py", line 161, in invoke
return super().invoke(ctx)
^^^^^^^^^^^^^^^^^^^
File "./venv/lib/python3.12/site-packages/click/core.py", line 1697, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "./venv/lib/python3.12/site-packages/click/core.py", line 1443, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "./venv/lib/python3.12/site-packages/click/core.py", line 788, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "./venv/lib/python3.12/site-packages/click/decorators.py", line 45, in new_func
return f(get_current_context().obj, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/rzeyde/src/trezor-firmware/python/src/trezorlib/cli/trezorctl.py", line 361, in get_session
if obj.features.model == "1" and obj.version < (1, 9, 0):
^^^^^^^^^^^
File "/home/rzeyde/src/trezor-firmware/python/src/trezorlib/cli/__init__.py", line 280, in version
if self._version is None:
^^^^^^^^^^^^^
AttributeError: 'TrezorConnection' object has no attribute '_version'. Did you mean: 'version'?
```

[no changelog]
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Uses a recognizable type or scope✓ Provides detailed explanatory context
The short version

What changed, and why it matters

This is a straightforward bug fix in the Python command-line tool `trezorctl`. A missing internal variable (`_version`) caused the `get-session` subcommand to crash with an error when used with older (legacy) Trezor devices. The patch adds the missing variable declaration and resets it when the connection closes. There is no security vulnerability here—just a broken feature being repaired.

Recommended action

No security action required. Treat as a normal bug-fix release for the Python tools package.

Security signals we found

01

No security-relevant change: missing attribute initialization causing a crash, not a vulnerability

02

No input validation, parsing, or trust-boundary changes

03

No cryptographic, authentication, or session-management logic altered

Risk score

Why this scored 20/100

Our methodology →
Potential impact 0/30
Exploitability 0/25
Stealth signal 0/15
Affected reach 5/15
Confidence 10/10
Evidence quality 5/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.