Skip to content

fix(core): fix device_menu crash on devices without a serial number#7022

Merged
cepetr merged 1 commit into
mainfrom
cepetr/device-menu-fix
May 29, 2026
Merged

fix(core): fix device_menu crash on devices without a serial number#7022
cepetr merged 1 commit into
mainfrom
cepetr/device-menu-fix

Conversation

@cepetr
Copy link
Copy Markdown
Contributor

@cepetr cepetr commented May 29, 2026

Fixes an issue on unprovisioned devices in development.

When a device has not yet been provisioned no serial number is assigned or written to OTP), opening the device menu on T3W1 throws an exception and results in a black screen.

With this fix, unprovisioned devices display N/A instead of a serial number.

@cepetr cepetr requested a review from obrusvit as a code owner May 29, 2026 07:12
@cepetr cepetr self-assigned this May 29, 2026
@trezor-bot trezor-bot Bot added this to Firmware May 29, 2026
@cepetr cepetr added the T3W1 Trezor Safe 7 label May 29, 2026
@github-project-automation github-project-automation Bot moved this to 🔎 Needs review in Firmware May 29, 2026
@cepetr cepetr removed the status in Firmware May 29, 2026
@cepetr cepetr moved this to 🔎 Needs review in Firmware May 29, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 29, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d2c69371-b8c1-4264-afb5-e2bda6585f95

📥 Commits

Reviewing files that changed from the base of the PR and between a743030 and ed55fa2.

📒 Files selected for processing (1)
  • core/src/apps/homescreen/device_menu.py

Walkthrough

The handle_device_menu function now guards the serial number retrieval with error handling. Instead of propagating exceptions when utils.serial_number() fails due to an unprovisioned device or unavailable serial access, the code catches RuntimeError and substitutes "N/A" as the display value. The menu construction logic remains otherwise unchanged.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely describes the main fix: preventing device_menu crashes on devices without a serial number.
Description check ✅ Passed The description clearly explains the issue, context (unprovisioned devices), and solution (displaying 'N/A'), though it doesn't follow the repository's template structure for core developers.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cepetr/device-menu-fix

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

en main(all)

model device_test click_test persistence_test
T2T1 test(all) main(all) test(all) main(all) test(all) main(all)
T3B1 test(all) main(all) test(all) main(all) test(all) main(all)
T3T1 test(all) main(all) test(all) main(all) test(all) main(all)
T3W1 test(all) main(all) test(all) main(all) test(all) main(all)

Latest CI run: 26623644989

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a crash in the homescreen “Device menu” on unprovisioned T3W1 devices where reading the serial number can fail (no SN in OTP yet). Instead of propagating the exception and ending in a black screen, the menu now shows a fallback value.

Changes:

  • Wrap serial number retrieval in a try/except to handle unprovisioned devices gracefully.
  • Display "N/A" in the About section when utils.serial_number() cannot be read.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread core/src/apps/homescreen/device_menu.py
@cepetr cepetr merged commit 5179038 into main May 29, 2026
116 of 164 checks passed
@cepetr cepetr deleted the cepetr/device-menu-fix branch May 29, 2026 10:39
@trezor-bot trezor-bot Bot moved this from 🔎 Needs review to 🤝 Needs QA in Firmware May 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T3W1 Trezor Safe 7

Projects

Status: 🤝 Needs QA

Development

Successfully merging this pull request may close these issues.

4 participants