Skip to content

Commit 3a17273

Browse files
authored
Error message enhancements (#2584)
1 parent 4e6195c commit 3a17273

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

workspaces/x2a/plugins/x2a-backend/templates/x2a-job-script.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,9 @@ case "${PHASE}" in
227227
# --source-dir DIRECTORY Source directory to analyze
228228
USER_REQ="${USER_PROMPT:-Analyze the Chef cookbooks and create a migration plan}"
229229
echo "Command: uv run app.py init --source-dir ${SOURCE_BASE} \"${USER_REQ}\""
230+
ERROR_MESSAGE="Unexpected error during init phase. See the job log for details."
230231
uv run app.py init --source-dir "${SOURCE_BASE}" "${USER_REQ}"
232+
ERROR_MESSAGE=""
231233

232234
# Copy output to target location
233235
# Note: x2a tool writes files to the source directory (--source-dir)
@@ -289,7 +291,9 @@ case "${PHASE}" in
289291

290292
USER_REQ="${USER_PROMPT:-Analyze the module '${MODULE_NAME}' for migration to Ansible}"
291293
echo "Command: uv run app.py analyze --source-dir ${SOURCE_BASE} \"${USER_REQ}\""
294+
ERROR_MESSAGE="Unexpected error during analyze phase. See the job log for details."
292295
uv run app.py analyze --source-dir "${SOURCE_BASE}" "${USER_REQ}"
296+
ERROR_MESSAGE=""
293297

294298
# Copy output to target location
295299
# Note: x2a tool produces migration-plan-{module_name}.md (spaces replaced with underscores)
@@ -344,12 +348,14 @@ case "${PHASE}" in
344348

345349
USER_REQ="${USER_PROMPT:-Migrate this module to Ansible}"
346350
echo "Command: uv run app.py migrate --source-dir ${SOURCE_BASE} --source-technology Chef --high-level-migration-plan ${PROJECT_PATH}/migration-plan.md --module-migration-plan ${OUTPUT_DIR}/migration-plan-${MODULE_NAME_SANITIZED}.md \"${USER_REQ}\""
351+
ERROR_MESSAGE="Unexpected error during migrate phase. See the job log for details."
347352
uv run app.py migrate \
348353
--source-dir "${SOURCE_BASE}" \
349354
--source-technology Chef \
350355
--high-level-migration-plan "${PROJECT_PATH}/migration-plan.md" \
351356
--module-migration-plan "${OUTPUT_DIR}/migration-plan-${MODULE_NAME_SANITIZED}.md" \
352357
"${USER_REQ}"
358+
ERROR_MESSAGE=""
353359

354360
# Copy output to target location
355361
# Note: x2a tool writes to ansible/roles/{module}/ in the source directory
@@ -397,7 +403,9 @@ case "${PHASE}" in
397403
# and writes to {project_id}/ansible-project/
398404
# It operates relative to CWD, so we run from TARGET_BASE
399405
pushd "${TARGET_BASE}"
406+
ERROR_MESSAGE="Unexpected error during publish phase (publish-project). See the job log for details."
400407
uv run --project /app /app/app.py publish-project "${PROJECT_DIR}" "${MODULE_NAME}"
408+
ERROR_MESSAGE=""
401409
popd
402410

403411
# Verify ansible-project was created
@@ -416,10 +424,12 @@ case "${PHASE}" in
416424
echo "=== Step 2: Publishing to AAP ==="
417425
echo "Command: uv run app.py publish-aap --target-repo ${TARGET_REPO_URL} --target-branch ${TARGET_REPO_BRANCH} --project-id ${PROJECT_DIR}"
418426
cd /app
427+
ERROR_MESSAGE="Unexpected error during publish phase (publish-aap). See the job log for details."
419428
PUBLISH_OUTPUT=$(uv run app.py publish-aap \
420429
--target-repo "${TARGET_REPO_URL}" \
421430
--target-branch "${TARGET_REPO_BRANCH}" \
422431
--project-id "${PROJECT_DIR}" 2>&1 | tee /dev/stderr)
432+
ERROR_MESSAGE=""
423433

424434
# Parse AAP project ID from output and construct URL
425435
AAP_PROJECT_ID=$(echo "${PUBLISH_OUTPUT}" | grep -oP 'ID: \K[0-9]+' | tail -1)

0 commit comments

Comments
 (0)