Skip to content

fix(connectors): return error for malformed Keycloak config response#396

Closed
hazelmayank wants to merge 1 commit into
microcks:masterfrom
hazelmayank:fix/keycloak-config-response-error
Closed

fix(connectors): return error for malformed Keycloak config response#396
hazelmayank wants to merge 1 commit into
microcks:masterfrom
hazelmayank:fix/keycloak-config-response-error

Conversation

@hazelmayank
Copy link
Copy Markdown
Contributor

Summary

This PR makes GetKeycloakURL defensive when parsing the /api/keycloak/config response.

Previously, the function used direct type assertions for fields like enabled, auth-server-url, and realm. If the server returned a malformed or unexpected response, the CLI could panic with an interface conversion error instead of returning a normal error.

This PR replaces those assertions with comma-ok checks and returns descriptive errors for malformed responses.

Why

This improves CLI reliability at the connector/API layer. Commands that communicate with a Microcks server should return clean errors instead of crashing on unexpected server responses.

What changed

  • Added safe parsing for enabled
  • Added safe parsing for auth-server-url
  • Added safe parsing for realm
  • Preserved existing behavior when Keycloak is disabled
  • Added tests for valid, disabled, and malformed Keycloak config responses

Test plan

  • go test -v -run TestGetKeycloakURL ./pkg/connectors/...
  • go test ./pkg/connectors/...
  • go build ./...

Note: go test ./... may still show the existing TestDeleteContext failure on master, which is unrelated to this PR and fixed separately in #334.

Closes #395

Signed-off-by: hazelmayank <mayankjeefinal@gmail.com>
@Harishrs2006
Copy link
Copy Markdown

duplicate #267 rubrx filed the same panic issue earlier , root issue is already tracked

@hazelmayank
Copy link
Copy Markdown
Contributor Author

Sorry I forgot to check if the same issue was addressed before

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.

pkg/connectors: GetKeycloakURL panics on malformed Keycloak config response

2 participants