Skip to content

refactor(node): Improve public key conflict handling#4486

Merged
jamesarich merged 1 commit into
mainfrom
fix/public-key-upsert
Feb 6, 2026
Merged

refactor(node): Improve public key conflict handling#4486
jamesarich merged 1 commit into
mainfrom
fix/public-key-upsert

Conversation

@jamesarich

Copy link
Copy Markdown
Collaborator

This commit refactors the logic for handling public key (PKC) updates for nodes in the database to be more robust and explicit.

Key changes:

  • Sets the public key to a specific ERROR_BYTE_STRING upon detecting a genuine mismatch between two valid, non-empty keys.
  • Preserves the existing key during routine node updates (e.g., position packets) that don't contain a new key.
  • Allows a node to recover from the error state if it later provides a valid, matching key.
  • Explicitly clears the public key for licensed (HAM) users, as they do not use PKC.
  • Updates the UI in Node Details and related components to visually indicate the error state, preventing users from copying the invalid key.

This new logic provides a clearer and more predictable state for node public keys, especially in cases of factory resets or hardware ID collisions.

This commit refactors the logic for handling public key (PKC) updates for nodes in the database to be more robust and explicit.

Key changes:
-   Sets the public key to a specific `ERROR_BYTE_STRING` upon detecting a genuine mismatch between two valid, non-empty keys.
-   Preserves the existing key during routine node updates (e.g., position packets) that don't contain a new key.
-   Allows a node to recover from the error state if it later provides a valid, matching key.
-   Explicitly clears the public key for licensed (HAM) users, as they do not use PKC.
-   Updates the UI in Node Details and related components to visually indicate the error state, preventing users from copying the invalid key.

This new logic provides a clearer and more predictable state for node public keys, especially in cases of factory resets or hardware ID collisions.

Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
@github-actions github-actions Bot added the bugfix PR tag label Feb 6, 2026
@codecov

codecov Bot commented Feb 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 9.21%. Comparing base (1e255a5) to head (8fd2699).
⚠️ Report is 3 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...in/org/meshtastic/core/database/dao/NodeInfoDao.kt 0.00% 17 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##            main   #4486      +/-   ##
========================================
- Coverage   9.21%   9.21%   -0.01%     
========================================
  Files        427     427              
  Lines      14342   14351       +9     
  Branches    2385    2389       +4     
========================================
  Hits        1322    1322              
- Misses     12767   12776       +9     
  Partials     253     253              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jamesarich jamesarich added this pull request to the merge queue Feb 6, 2026
Merged via the queue into main with commit cab3940 Feb 6, 2026
8 of 9 checks passed
@jamesarich jamesarich deleted the fix/public-key-upsert branch February 6, 2026 20:04
@prokrypt

prokrypt commented Feb 11, 2026

Copy link
Copy Markdown
Contributor
  • Explicitly clears the public key for licensed (HAM) users, as they do not use PKC.

could this possibly be abused turned into a feature to clear keys of other nodes?

@jamesarich

Copy link
Copy Markdown
Collaborator Author
  • Explicitly clears the public key for licensed (HAM) users, as they do not use PKC.

could this possibly be abused turned into a feature to clear keys of other nodes?

good eye #4555

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

Labels

bugfix PR tag

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants