Skip to content

fix(cli): classify failures and stop panicking in the client library#489

Open
Caesarsage wants to merge 2 commits into
microcks:masterfrom
Caesarsage:pr1/classify-errors-and-depanic
Open

fix(cli): classify failures and stop panicking in the client library#489
Caesarsage wants to merge 2 commits into
microcks:masterfrom
Caesarsage:pr1/classify-errors-and-depanic

Conversation

@Caesarsage

Copy link
Copy Markdown
Contributor

Part of the Microcks CLI v2 work #255.

Introduces a small Failure Kind vocabulary in pkg/errors (Kind, Wrap/Wrapf, KindOf, and an ErrTestFailed sentinel) and makes the client library return classified errors instead of panicking or exiting.

Why

pkg/connectors and keycloak_client previously panic'd on runtime errors (bad response body, unreachable server). A library that can take down its host process is unsafe to embed, which the planned VS Code extension needs to do. Kinds are the library's vocabulary; exit codes stay a CLI concern (added in next PR ()), so pkg/* never depends on them.

Notable

Fixes two real latent bugs found while de-panicking:

  • Keycloak swallowed request-creation errors: nil-pointer dereference.
  • Unchecked openIDResp["access_token"].(string): the CLI crashed on a Keycloak 401 instead of reporting it.

Scope / safety

Additive and non-breaking: the legacy CheckError/Fatal shim and the existing constructor signatures are untouched here (removed/changed in later PRs). Build + tests green.

Signed-off-by: caesarsage <destinyerhabor6@gmail.com>
Signed-off-by: caesarsage <destinyerhabor6@gmail.com>
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