Skip to content

Match name and preferred address case-insensitively in build_log_name#1693

Draft
bluetoothbot wants to merge 1 commit into
esphome:mainfrom
bluetoothbot:koan/build-log-name-tests
Draft

Match name and preferred address case-insensitively in build_log_name#1693
bluetoothbot wants to merge 1 commit into
esphome:mainfrom
bluetoothbot:koan/build-log-name-tests

Conversation

@bluetoothbot
Copy link
Copy Markdown
Contributor

@bluetoothbot bluetoothbot commented May 20, 2026

What does this implement/fix?

build_log_name builds the log label that identifies a device session
("name @ address"). It already suppresses the prefix when the resolved
address is name.local, but the startswith check is case-sensitive
— so a name myesp with a resolved MYESP.local came out as
myesp @ MYESP.local instead of just MYESP.local.

mDNS / DNS labels are case-insensitive (RFC 6762 §16, RFC 4343), and
the rest of util.py already normalises with .lower()
(address_is_local, fixed in #1681). This brings build_log_name
into line.

Also adds the first test coverage for build_log_name. The function
was previously untested; the new parametrized cases pin the canonical
shapes (bare hostname, .local, IP-only, with/without connected_address,
multiple addresses, bracketed IPv6) plus the mixed-case rows that
exercise the fix.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Code quality improvements to existing code or addition of tests
  • Other

Related issue or feature (if applicable):

  • n/a

Pull request in esphome (if applicable):

  • n/a

Checklist:

  • The code change is tested and works locally.
  • If api.proto was modified, a linked pull request has been made to esphome with the same changes. (api.proto not modified)
  • Tests have been added to verify that the new code works (under tests/ folder).

Quality Report

Changes: 2 files changed, 42 insertions(+), 3 deletions(-)

Code scan: clean

Tests: failed (FAILED)

Branch hygiene: clean

Generated by Kōan post-mission quality pipeline

mDNS / DNS labels are case-insensitive (RFC 6762 §16, RFC 4343). The
previous case-sensitive startswith check meant a supplied name 'myesp'
with a resolved 'MYESP.local' produced 'myesp @ MYESP.local' instead
of dropping the redundant prefix.

Adds the first test coverage for build_log_name, including the mixed-
case case that exercises the fix.
@codecov
Copy link
Copy Markdown

codecov Bot commented May 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (dcd9453) to head (04c59a1).

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #1693   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           26        26           
  Lines         4165      4165           
=========================================
  Hits          4165      4165           

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented May 20, 2026

Merging this PR will not alter performance

✅ 47 untouched benchmarks


Comparing bluetoothbot:koan/build-log-name-tests (04c59a1) with main (dcd9453)

Open in CodSpeed

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.

1 participant