Skip to content

fix: preserve channel names when device sends empty names#1703

Merged
Yeraze merged 1 commit into
mainfrom
fix/preserve-channel-names-1567
Jan 30, 2026
Merged

fix: preserve channel names when device sends empty names#1703
Yeraze merged 1 commit into
mainfrom
fix/preserve-channel-names-1567

Conversation

@Yeraze

@Yeraze Yeraze commented Jan 30, 2026

Copy link
Copy Markdown
Owner

Summary

  • Fixes issue where Android/iOS virtual node clients show "Channel Name" placeholder text instead of actual channel names
  • Prevents device reconnections from overwriting existing channel names with empty strings

Problem

When a Meshtastic device reconnects, it often sends channel configuration with empty name fields (especially for the default Primary channel). The upsertChannel function was unconditionally overwriting the database channel name with the incoming value, even when empty. This caused:

  1. Existing channel names to be wiped on device reconnection
  2. Android/iOS apps connected to the virtual node to display "Channel Name" placeholder

Solution

When updating a channel, check if the incoming name is empty. If so, preserve the existing non-empty name from the database instead of overwriting it.

const effectiveName = data.name || existingChannel.name;

Test plan

  • TypeScript compiles without errors
  • All tests pass (2328 passed)
  • Manual testing: Set a channel name, reconnect device, verify name is preserved
  • Manual testing: Connect Android app to virtual node, verify channel names display correctly

Fixes #1567

🤖 Generated with Claude Code

When a Meshtastic device reconnects, it often sends channel configuration
with empty name fields (especially for the default Primary channel). This
was overwriting existing non-empty channel names in the database, causing
Android/iOS virtual node clients to display "Channel Name" placeholder text.

Fix: When updating a channel, if the incoming name is empty but an existing
non-empty name exists in the database, preserve the existing name instead
of overwriting it with empty.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jan 30, 2026

Copy link
Copy Markdown

Claude finished @Yeraze's task —— View job


Analyzing this pull request and will provide code review feedback

Review Checklist

  • Read repository guidelines and context
  • Analyze the code changes in detail
  • Check for bugs and edge cases
  • Assess performance implications
  • Review security considerations
  • Evaluate test coverage
  • Provide comprehensive feedback

Code Review Summary

This is a well-implemented fix for issue #1567. The solution elegantly addresses the problem of device reconnections overwriting existing channel names with empty strings.

✅ Strengths

Clean Implementation

  • The fix is minimal and targeted - only changes what's necessary
  • Uses clear, self-documenting variable name: effectiveName
  • Consistent application across all three database backends (SQLite, PostgreSQL, MySQL)
  • Excellent logging that aids debugging and troubleshooting

Correct Logic

  • The fallback logic data.name || existingChannel.name properly preserves existing names when incoming data is empty
  • Handles both empty strings and null/undefined values correctly
  • Maintains backward compatibility - doesn't break existing functionality

🔍 Technical Assessment

Performance: ✅ No concerns

  • No additional database queries added
  • Minimal computational overhead
  • Change is confined to update path only

Security: ✅ No concerns

  • Uses existing parameterized queries via Drizzle ORM
  • No new attack vectors introduced
  • Maintains existing input validation patterns

Database Compatibility: ✅ Excellent

  • Properly supports all three database backends per repository guidelines
  • Uses Drizzle ORM as required by CLAUDE.md
  • Follows established patterns for multi-database operations

🧪 Test Coverage Assessment

Existing Coverage: The current tests in src/services/database.test.ts cover basic upsert scenarios but lack coverage for this specific edge case.

Recommended Test Addition (optional but valuable):

it('should preserve existing channel name when incoming name is empty', () => {
  // Create channel with name
  db.upsertChannel({ id: 1, name: 'MyChannel', psk: 'secret123' });
  
  // Simulate device reconnection with empty name
  db.upsertChannel({ id: 1, name: '', psk: 'secret123' });
  
  const channel = db.getChannelById(1);
  expect(channel.name).toBe('MyChannel'); // Should preserve original name
});

🎯 Edge Case Analysis

Handled Correctly:

  • Empty string ("") incoming names ✅
  • Null/undefined incoming names ✅
  • Existing channel with empty name - will remain empty ✅
  • New channel creation - uses incoming name as expected ✅

No Issues Found: The logic handles all reasonable edge cases appropriately.

📋 Manual Testing Recommendations

Since this affects device reconnection behavior, the manual test plan in the PR description is appropriate:

  • ✅ Set a channel name
  • ✅ Force device reconnection
  • ✅ Verify name preservation
  • ✅ Test Android/iOS virtual node display

Final Assessment

This is a high-quality fix that directly addresses the reported issue with minimal risk. The implementation follows repository conventions, maintains database compatibility, and includes helpful logging for troubleshooting.

Recommendation: ✅ Approve - Ready to merge

The only minor enhancement would be adding the suggested test case, but the existing manual testing plan provides adequate coverage for this specific bug fix.

@Yeraze Yeraze merged commit 36bee06 into main Jan 30, 2026
14 checks passed
@Yeraze Yeraze deleted the fix/preserve-channel-names-1567 branch January 30, 2026 14:37
@ffolkes

ffolkes commented Jan 31, 2026

Copy link
Copy Markdown

I really appreciate your efforts on this issue. I hate to be the bearer of bad news, but it is still happening on 3.4.2.

I realize there are two aspects of this: a.) how Meshmonitor handles the aftermath of the drop/reconnect, and b.) what is causing the drop in the first place. Based on the Info tab of Meshmonitor, I have noticed the virtual node connection seems to be reset every 3 hours. I.e. it said connected at 3:03, channel names worked fine until now, and when I looked at the tab, it says connected at 6:03 and vn- has indeed been incremented.

If other node hardware is doing 100% uptime, then I am wondering if there may be instability in the esp32 firmware my Heltec V4 is running which is causing it to momentarily drop every 3 hours. I don't have any other node hardware to test with. I left ping running for a while, and out of ~3000 packets to the node, 3 were lost, which is suspicious. I googled "esp32 dropping every 3 hours" and found others experiencing various WiFi drops with other esp32-based hardware (home automation, etc). I'm going to try a static IP and see if that helps any.

Thank you again for your work, Meshmonitor is great!

dpaschal pushed a commit to dpaschal/meshcore-monitor that referenced this pull request Mar 17, 2026
… (Yeraze#1703)

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] After upgrading to 3.1.x all channels on Meshtastic app show as "Channel Name"

2 participants