Skip to content

issue #7302 : Start Action fails when there is a space in the name of the Action via the Docker container#7367

Open
mattcasters wants to merge 1 commit into
apache:mainfrom
mattcasters:issue-7302
Open

issue #7302 : Start Action fails when there is a space in the name of the Action via the Docker container#7367
mattcasters wants to merge 1 commit into
apache:mainfrom
mattcasters:issue-7302

Conversation

@mattcasters

Copy link
Copy Markdown
Contributor

Walkthrough - Fixing Docker variable quoting for HOP_START_ACTION

This walkthrough describes the root cause and the fix for the issue where using HOP_START_ACTION with spaces in the Docker container fails.

Root Cause Analysis

In docker/resources/load-and-execute.sh, options were concatenated into a single string variable HOP_EXEC_OPTIONS:

HOP_EXEC_OPTIONS="${HOP_EXEC_OPTIONS} --startaction=${HOP_START_ACTION}"

When executing the underlying hop-run.sh or hop command, ${HOP_EXEC_OPTIONS} was passed unquoted to allow multiple flags to be passed as separate arguments:

"${DEPLOYMENT_PATH}"/hop-run.sh \
  --file="${HOP_FILE_PATH}" \
  --runconfig="${HOP_RUN_CONFIG}" \
  --parameters="${HOP_RUN_PARAMETERS}" \
  ${HOP_EXEC_OPTIONS} \
  ...

Due to the lack of quoting around ${HOP_EXEC_OPTIONS}, the shell performed word splitting on whitespace. If HOP_START_ACTION contained spaces (e.g. "My Fancy Action"), the parameter was split into multiple arguments: --startaction=My, Fancy, and Action.

Implementation Details

To properly preserve spaces in arguments, HOP_EXEC_OPTIONS was converted into a Bash array (HOP_EXEC_OPTIONS=()).

Options are now appended to the array:

  • HOP_EXEC_OPTIONS+=("--level=${HOP_LOG_LEVEL}")
  • HOP_EXEC_OPTIONS+=("--system-properties=${HOP_SYSTEM_PROPERTIES}")
  • HOP_EXEC_OPTIONS+=("--project=${HOP_PROJECT_NAME}")
  • HOP_EXEC_OPTIONS+=("--environment=${HOP_ENVIRONMENT_NAME}")
  • HOP_EXEC_OPTIONS+=("--metadata-export=${HOP_RUN_METADATA_EXPORT}")
  • HOP_EXEC_OPTIONS+=("--startaction=${HOP_START_ACTION}")

When executing downstream scripts, the array is expanded with quotes "${HOP_EXEC_OPTIONS[@]}", which correctly preserves each option (including those with spaces) as a single distinct argument.

Modified Files

  • load-and-execute.sh

Testing

Ran integration-tests/scripts/run-tests-docker.sh PROJECT_NAME=actions to make sure the old behavior still works as expected.

…ame of the Action via the Docker container
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant