Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sm-ssh-ide script failure on grep during init-ssm #62

Open
hidemire opened this issue Jun 6, 2024 · 1 comment
Open

sm-ssh-ide script failure on grep during init-ssm #62

hidemire opened this issue Jun 6, 2024 · 1 comment
Assignees

Comments

@hidemire
Copy link

hidemire commented Jun 6, 2024

Hello, firstly, thank you for the wonderful library!

We encountered a problem when initializing ssm in the case when the ExecutionRole is not available for the user-profile, but only for the domain.

The sm-ssh-ide script, fails due to the use of grep within a pipeline combined with set -o pipefail.
The grep command can exit with code 1 if "ExecutionRole" is not found, triggering the pipefail behavior and causing the script to terminate.

Steps to Reproduce:

  1. Run the script in an environment where "ExecutionRole" is not present in the user_profile_json.
  2. Observe that the script fails due to grep exiting with code 1.

Suggested Solution:

  1. Temporarily disable pipefail and re-enable after the condition is processed.
set +o pipefail
# execution_role extraction
set -o pipefail
  1. Add || true;
execution_role=$(echo "$user_profile_json" | {grep "ExecutionRole" || true;} \
      | sed -e 's/^.*"ExecutionRole": \"\([^"]*\)\".*$/\1/')
# ...
execution_role=$(echo "$domain_json" | {grep "ExecutionRole" || true;} \
        | sed -e 's/^.*"ExecutionRole": \"\([^"]*\)\".*$/\1/')
@ivan-khvostishkov
Copy link
Contributor

Hi, @hidemire , thank you for pointing to this bug and to the solutions! I've applied the second solution to the main branch and it will appear in the next release.

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

No branches or pull requests

2 participants