Zeroconf registration loops forever on a second name conflict
π 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>-1is also taken, the loop never exits. - The
i > SERVICE_RENAME_ATTEMPTSguard (100) never fires, sinceistays1. test_register_rename_gives_uppatchesSERVICE_RENAME_ATTEMPTSto0, 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
- In a test, make
Zeroconf.check_serviceraiseNonUniqueNameExceptionon every call, withSERVICE_RENAME_ATTEMPTSset above0. - Call
ZeroconfNetworkDiscovery.register(instance). - It never returns.
Acceptance Criteria
- [ ] Successive conflicts try
<instance.id>-1,<instance.id>-2, β¦ in order. - [ ]
register()raisesNonUniqueNameExceptiononceSERVICE_RENAME_ATTEMPTSis exceeded. - [ ] Tests in
kolibri/core/discovery/test/test_zeroconf_transport.pycover both cases withSERVICE_RENAME_ATTEMPTSabove0.
AI usage
Claude Code found this while converting the line to an f-string for #15311 and drafted the issue from the code.
Hi! π
This issue is available for contribution and supports self-assignment. Here's how to get started:
- Comment
/assignto 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.
/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.
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.
/unassign
I'm stepping back from this issue so it remains available to another contributor.
Thanks @natesute β unassigned you and removed community-contribution-in-progress; the issue is open for another contributor.
I can continue with this fix; please keep the assignment. I'll include the AI-usage disclosure required by the PR template.
@natesute Comment /assign to take it back β self-assignment goes through the bot so its limits apply.
/assign
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.