chore(core): improve logging when USE_N4W1 is unset
What changed, and why it matters
This is a minor code cleanup that changes when a debug-only warning message is printed. It does not fix or introduce any security issue. The change simply avoids logging a misleading warning when no backup method is selected in a non-production debug build.
No security action required. This is a routine logging improvement with no security relevance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
In core/src/apps/management/recovery_device/layout.py, the choose_handler function (used only when USE_N4W1 is unset, i.e., non-Trezor Safe 5 hardware) was refactored. Previously it imported BackupMethod and logged a warning whenever method was not BackupMethod.Display. Now it only logs a warning in __debug__ builds when method is neither None nor BackupMethod.Display. This prevents a confusing warning when method is None. The functional return value (_DisplayHandler) is unchanged.
Changed components
core/src/apps/management/recovery_device/layout.pyInspect captured patch +6 / −4
diff --git a/core/src/apps/management/recovery_device/layout.py b/core/src/apps/management/recovery_device/layout.py
index 95e3e3f5..16352c03 100644
--- a/core/src/apps/management/recovery_device/layout.py
+++ b/core/src/apps/management/recovery_device/layout.py
@@ -281,12 +281,14 @@ class _DisplayHandler:
if not utils.USE_N4W1:
async def choose_handler(method: BackupMethod | None) -> type[RecoveryHandler]:
- from trezor.enums import BackupMethod
- if method is not BackupMethod.Display and __debug__:
- from trezor import log
+ if __debug__:
+ from trezor.enums import BackupMethod
- log.warning(__name__, "Unsupported backup method: %s", method)
+ if method not in (None, BackupMethod.Display):
+ from trezor import log
+
+ log.warning(__name__, "Unsupported backup method: %s", method)
return _DisplayHandler
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.