ctrl-space-labs / gendox-core

Gendox: "Generate. Train. Evolve."
GNU Affero General Public License v3.0
5 stars 0 forks source link

Resolve `jq` Installation and Duplicate Client Creation in Keycloak Docker Configuration #328

Open gyfantidis opened 1 month ago

gyfantidis commented 1 month ago

Ticket Title: Resolve jq Installation and Duplicate Client Creation in Keycloak Docker Configuration

Description:

When attempting to run the Keycloak initialization script (gendox-local-init.sh) multiple times, there are two primary issues that prevent successful execution:

  1. jq Not Found During Execution: In the Dockerfile, jq is installed in a separate build stage but is not available in the final Keycloak image, causing failures in the script (gendox-local-init.sh) at lines 61 and 110. Specifically, the command:

    CLIENT_UUID=$($KCADM get clients -r "$REALM_NAME" -q clientId="$CLIENT_ID" --fields id --format json | jq -r '.[0].id')

    results in an error due to the absence of jq, which is required to parse JSON output.

  2. Duplicate Client Creation: When jq is missing, the script fails to retrieve existing client IDs. As a result, the script attempts to recreate the client, leading to a unique constraint violation:

    ERROR: duplicate key value violates unique constraint "uk_b71cjlbenv945rb6gcon438at"

    This indicates the script is not identifying existing clients correctly, causing duplication issues in Keycloak.

Proposed Solution:

Additional Notes:

Log output for troubleshooting:

CLIENT_UUID=$($KCADM get clients -r "$REALM_NAME" -q clientId="$CLIENT_ID" --fields id --format json | jq -r '.[0].id')
ERROR: duplicate key value violates unique constraint "uk_b71cjlbenv945rb6gcon438at"