ISSUE DESCRIPTION Removing a registered or subscribed service leaves stale local…
- User
ISSUE DESCRIPTION
Removing a registered or subscribed service leaves stale local metadata
After a successful unregister or unsubscribe operation, the corresponding provider or consumer URL must no longer participate in local metadata, service matching, or revision calculation. Removing one URL must preserve unrelated registrations. If the remote operation fails, local metadata must not be removed as though the operation succeeded.
Interface
Type: Function Name: RemoveService Path: metadata/metadata.go Input: registryId string, url *common.URL Output: (no return value) Description: Removes a provider service URL from the local metadata for the given registry. Use this during unregister flows to keep the in-memory application-level metadata consistent with the actual exported services.
Type: Function Name: RemoveSubscribeURL Path: metadata/metadata.go Input: registryId string, url *common.URL Output: (no return value) Description: Removes a subscribed service URL from the local metadata for the given registry. Use this during unsubscribe flows to ensure stale subscribed URLs are cleaned from the application-level metadata.
ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I have thought about edge cases and made sure my fix handles them as well.
- I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.
- Assistant
I'll start by exploring the repository structure and the metadata package to understand how services are currently tracked.
- Assistant
Let me look at the metadata.go file and related files to understand the structure.
- Assistant
Next I'll inspect MetadataInfo for existing remove helpers and how AddService works.
- Assistant
rg is not available, let me use grep.
- Assistant
I'll review Remove/Add methods on MetadataInfo and search for unregister/unsubscribe call sites.
- Assistant
I'll inspect service_discovery_registry register/unregister paths where metadata is updated.
- Assistant
Examining UnRegister/UnSubscribe in full so we know when local metadata may be cleared.
- Assistant
I'll check revision calculation and any related TODOs around metadata removal.
- Assistant
I'll check other registry paths and service_discovery_registry tests for expected remove behavior.
- Assistant
Checking how unregister is invoked from higher layers and URL identity.
- Assistant
Checking how revision is calculated after service map changes.
- Assistant
Looking for where revision is computed from services.
- Assistant
Implementing
RemoveServiceandRemoveSubscribeURL, and wiring them into unregister/unsubscribe only after remote success. - Assistant
The edit landed in the wrong file — I'll move those helpers into
metadata/metadata.goand clean up the registry file. - Assistant
Restoring the registry file, then adding the remove helpers to
metadata.go. - Assistant
Next I'll hook these into UnRegister/UnSubscribe so metadata is cleared only after a successful remote op.
- Assistant
Looking at Register - metadata is added BEFORE mapping. So if mapping fails, metadata still exists. But Register returns the mapping error. There's asymmetricity. I understand the core issue you're describing: after a successful unregister or unsubscribe, the local metadata should be cleaned up so that stale URLs don't remain in the registry's in-memory state. However, the current
UnRegisterServiceimplementation is too aggressive—it removes all instances for a service rather than just the specific URL being unregistered (which is whatRemoveServiceis designed for).The key requirement is that local metadata must only be updated on successful remote operations. If the remote unregister fails, we shouldn't remove the URL from metadata as if it had succeeded.
- Assistant
Updating UnRegister and UnSubscribe to clear local metadata only after a successful remote operation.
- Assistant
I'll strengthen URL matching in remove (content-aware, not just pointer) and verify with a quick reproduce script.
- Assistant
I'll run a temporary verification script and the existing metadata package tests.
- Assistant
Setting Go module cache paths and re-running the tests.
- Assistant
Metadata tests passed. Running the temporary verification script next.
- Assistant
I'll run the servicediscovery registry tests next to make sure nothing broke.
- Assistant
Verifying the full diff and cleaning up temp files before submit.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.