kolibri icon indicating copy to clipboard operation
kolibri copied to clipboard

Zeroconf registration loops forever on a second name conflict

Open rtibblesbot opened this issue 2 months ago β€’ 9 comments

πŸ™‚ Looking for an issue? Welcome! This issue is open for contribution. If this is the first time you’re requesting an issue, please:

  • Read Contributing guidelines carefully. Pay extra attention to Using generative AI. Pull requests and comments that don’t follow the guidelines won’t be answered.
  • Confirm that you’ve read the guidelines in your comment.

Target branch: develop

Observed behavior

ZeroconfNetworkDiscovery._register never increments i:

  • After the first NonUniqueNameException, every retry uses <instance.id>-1.
  • If <instance.id>-1 is also taken, the loop never exits.
  • The i > SERVICE_RENAME_ATTEMPTS guard (100) never fires, since i stays 1.
  • test_register_rename_gives_up patches SERVICE_RENAME_ATTEMPTS to 0, so the guard fires on the first conflict and the test passes despite the bug.

User-facing consequences

A device whose zeroconf name and -1 name are both taken on the LAN never calls register_service, so peers never discover it.

Steps to reproduce

  1. In a test, make Zeroconf.check_service raise NonUniqueNameException on every call, with SERVICE_RENAME_ATTEMPTS set above 0.
  2. Call ZeroconfNetworkDiscovery.register(instance).
  3. It never returns.

Acceptance Criteria

  • [ ] Successive conflicts try <instance.id>-1, <instance.id>-2, … in order.
  • [ ] register() raises NonUniqueNameException once SERVICE_RENAME_ATTEMPTS is exceeded.
  • [ ] Tests in kolibri/core/discovery/test/test_zeroconf_transport.py cover both cases with SERVICE_RENAME_ATTEMPTS above 0.

AI usage

Claude Code found this while converting the line to an f-string for #15311 and drafted the issue from the code.

rtibblesbot avatar Sep 23 '26 20:09 rtibblesbot

Hi! πŸ‘‹

This issue is available for contribution and supports self-assignment. Here's how to get started:

  • Comment /assign to assign yourself to this issue
  • You can have up to 2 issues assigned at a time across all community repos
  • Dropping an issue has a 7-day cooldown before the slot opens up
  • Link your pull request to this issue when you submit it

πŸ“– Read the Contributing guidelines before starting.

Are you preparing for Google Summer of Code? See our GSoC guidelines.

learning-equality-bot avatar Sep 30 '26 02:09 learning-equality-bot

/assign

I've read the contribution guidelines. I'll fix the rename counter and cover successive name conflicts and exhaustion with a nonzero retry limit.

natesute avatar Sep 30 '26 03:09 natesute

Hi! πŸ‘‹

You've been assigned to this issue. Here's what to do next:

  • Read the issue description carefully and make sure you understand the requirements
  • Link your pull request to this issue when you submit it
  • If you can no longer work on this, unassign yourself so others can pick it up

Good luck! 😊

Are you preparing for Google Summer of Code? See our GSoC guidelines.

learning-equality-bot avatar Sep 30 '26 03:09 learning-equality-bot

/unassign

I'm stepping back from this issue so it remains available to another contributor.

natesute avatar Sep 30 '26 03:09 natesute

Thanks @natesute β€” unassigned you and removed community-contribution-in-progress; the issue is open for another contributor.

rtibblesbot avatar Sep 30 '26 03:09 rtibblesbot

I can continue with this fix; please keep the assignment. I'll include the AI-usage disclosure required by the PR template.

natesute avatar Sep 30 '26 03:09 natesute

@natesute Comment /assign to take it back β€” self-assignment goes through the bot so its limits apply.

rtibblesbot avatar Sep 30 '26 03:09 rtibblesbot

/assign

natesute avatar Sep 30 '26 03:09 natesute

Hi! πŸ‘‹

You've been assigned to this issue. Here's what to do next:

  • Read the issue description carefully and make sure you understand the requirements
  • Link your pull request to this issue when you submit it
  • If you can no longer work on this, unassign yourself so others can pick it up

Good luck! 😊

Are you preparing for Google Summer of Code? See our GSoC guidelines.

learning-equality-bot avatar Sep 30 '26 03:09 learning-equality-bot