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
Open
issue #7302 : Start Action fails when there is a space in the name of the Action via the Docker container#7367mattcasters wants to merge 1 commit into
mattcasters wants to merge 1 commit into
Conversation
…ame of the Action via the Docker container
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_ACTIONwith spaces in the Docker container fails.Root Cause Analysis
In
docker/resources/load-and-execute.sh, options were concatenated into a single string variableHOP_EXEC_OPTIONS:HOP_EXEC_OPTIONS="${HOP_EXEC_OPTIONS} --startaction=${HOP_START_ACTION}"When executing the underlying
hop-run.shorhopcommand,${HOP_EXEC_OPTIONS}was passed unquoted to allow multiple flags to be passed as separate arguments:Due to the lack of quoting around
${HOP_EXEC_OPTIONS}, the shell performed word splitting on whitespace. IfHOP_START_ACTIONcontained spaces (e.g."My Fancy Action"), the parameter was split into multiple arguments:--startaction=My,Fancy, andAction.Implementation Details
To properly preserve spaces in arguments,
HOP_EXEC_OPTIONSwas 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
Testing
Ran
integration-tests/scripts/run-tests-docker.sh PROJECT_NAME=actionsto make sure the old behavior still works as expected.