Description
Describe the bug
When the local configuration file contains an orphaned or broken context (for example, referencing a server or user that no longer exists in servers or users), the CLI becomes difficult to recover:
microcks context(list) aborts completely, preventing users from viewing even valid contexts.microcks context <name> --deletealso fails before removing the context, making it impossible to clean up the broken entry through the CLI.
As a result, users are forced to manually locate and edit ~/.config/microcks/config to remove the invalid YAML entry.
Expected behavior
microcks contextshould list all defined contexts, displaying the server reference fromcontextRef.Serverwithout failing when the full context resolution cannot find the associated server or user.microcks context <name> --deleteshould remove the context reference directly fromcontexts, without requiringResolveContext(context)to succeed first.- Garbage collection of unreferenced servers or users during context deletion should be idempotent. If a server or user is already missing, the command should continue without failing or aborting the configuration save.
Actual behavior
-
Running
microcks contextfails with:Error: resolving context "<context-name>": Server '<server-name>' undefinedAs a result, no contexts are displayed to the user.
-
Running
microcks context <context-name> --deletefails with:Error: Server '<server-name>' undefinedThe context is not deleted, and the configuration file on disk remains unchanged.
How to Reproduce?
Steps to Reproduce
-
Create a configuration file (e.g.
/tmp/test-configor~/.config/microcks/config) containing one valid context and one orphaned context referencing a non-existent server:current-context: prod contexts: - name: prod server: https://microcks-prod.example.com user: prod-user - name: broken-ctx server: https://missing-server.example.com user: prod-user servers: - server: https://microcks-prod.example.com users: - name: prod-user
-
Attempt to list contexts:
microcks context --config /tmp/test-config
Result: The command aborts with:
Error: resolving context "broken-ctx": Server 'https://missing-server.example.com' undefinedNo contexts are displayed, including the valid
prodcontext. -
Attempt to delete the broken context:
microcks context broken-ctx --delete --config /tmp/test-config
Result: The command aborts with:
Error: Server 'https://missing-server.example.com' undefinedThe
broken-ctxentry remains in the configuration file.
Microcks version or git rev
master branch (HEAD)
Install method (docker-compose, helm chart, operator, docker-desktop extension,...)
Built from source (make build-local) / binary release
Additional information
No response
Activity
AyushmanMohapatra015 commentedon Nov 19, 2026
I reproduced this on current
master(d3fced2) using a temporary config with one valid context and one context referencing a missing server.Listing contexts aborts when resolving the broken entry, and deleting that entry fails before
RemoveContextis reached, leaving the configuration unchanged.I’d like to fix both recovery paths and add regression tests covering listing and deleting an orphaned context. Would this approach be welcome?
aryarathoree commentedon Nov 19, 2026
@AyushmanMohapatra015 actually I am waiting for the maintainers to review the issue and then will be working on it.
AyushmanMohapatra015 commentedon Nov 19, 2026
Sure @aryarathoree thanks for lmk !!
aryarathoree commentedon Nov 19, 2026
hey @Caesarsage , would love to know your take on this issue
Harsh4902 commentedon Nov 25, 2026
Hey @aryarathoree , I've checked the issue. Feel free to raise a PR with the fix.