Skip to content

fix: node search by keeping denormalized name columns up to date and backfilling existing nodes#3839

Merged
jamesarich merged 1 commit into
meshtastic:mainfrom
mdecourcy:fix/node-search-and-denormalized-columns
Nov 28, 2025
Merged

fix: node search by keeping denormalized name columns up to date and backfilling existing nodes#3839
jamesarich merged 1 commit into
meshtastic:mainfrom
mdecourcy:fix/node-search-and-denormalized-columns

Conversation

@mdecourcy

Copy link
Copy Markdown
Contributor

What this change does

  • Populate denormalized name columns on write: Centralizes NodeEntity validation in NodeInfoDao so that on every upsert we:
    • Copy user.publicKey into NodeEntity.publicKey (for lazy migration and consistency).
    • Populate longName and shortName from the MeshProtos.User payload when the user is not a placeholder (hwModel != UNSET).
  • Backfill existing rows for search: Adds a backfillDenormalizedNames() DAO method (exposed via NodeInfoWriteDataSource and SwitchingNodeInfoWriteDataSource) that:
    • Scans all nodes and fills in missing longName/shortName from the associated user protobuf.
    • Skips placeholder/default users to avoid polluting search with dummy entries.
  • Run backfill once on startup: NodeRepository now kicks off the backfill in processLifecycle.coroutineScope.launchWhenCreated on the IO dispatcher so existing databases get corrected without blocking the UI.
  • Wire search & filters through the repository:
    • NodeRepository.getNodes(...) exposes a flow backed by the Room query in NodeInfoDao.getNodes, which now searches against the denormalized long_name / short_name columns and node ID (both hex and decimal).
    • NodeListViewModel combines user preferences and filter state into a single NodeFilterState, then calls nodeRepository.getNodes with sort, filterText, and flags (includeUnknown, onlyOnline, onlyDirect, infrastructure/ignored filters).
    • An additional unfilteredNodeList flow is provided for call sites that need the raw list without UI filters.

Why this fixes the bug

  • Previously, node search could fail or behave inconsistently because the denormalized name columns were not reliably populated, especially for existing databases or nodes created before the columns were introduced.
  • By ensuring denormalized columns are populated on every write and backfilled once on startup, the SQL query powering search now has consistent data to match against, so:
    • Searching by node long/short name works for both new and existing nodes.
    • Searching by node ID (hex or decimal) is supported via the updated query conditions.
  • The existing public-key validation and impersonation safeguards remain intact, while search and sorting now operate on well-defined, denormalized fields.

@github-actions github-actions Bot added the bugfix PR tag label Nov 27, 2025
@jamesarich jamesarich added this pull request to the merge queue Nov 28, 2025
Merged via the queue into meshtastic:main with commit 1c0dc48 Nov 28, 2025
5 checks passed
@codecov

codecov Bot commented Nov 28, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 0.54%. Comparing base (1c37842) to head (9d42db9).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
.../meshtastic/core/data/repository/NodeRepository.kt 0.00% 3 Missing ⚠️
...ata/datasource/SwitchingNodeInfoWriteDataSource.kt 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##            main   #3839      +/-   ##
========================================
- Coverage   0.54%   0.54%   -0.01%     
========================================
  Files        386     386              
  Lines      22559   22563       +4     
  Branches    2838    2838              
========================================
  Hits         122     122              
- Misses     22416   22420       +4     
  Partials      21      21              

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

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