Skip to content

[Bug] Script crashes with "bad array subscript" when service_mesh input is empty #104

@PragalvaXFREZ

Description

@PragalvaXFREZ

Description

The mesheryctl.sh script crashes with a bash error when the service_mesh input is not provided, even though it's marked as optional in action.yml.

Error

mesheryctl.sh: line 61: adapters: bad array subscript

Root Cause

In mesheryctl.sh, when using a config file (the else branch starting at line 58), the script immediately accesses:

shortName=$(echo ${adapters[$service_mesh]} | cut -d ':' -f1)

If service_mesh is empty (not provided by the caller), bash throws "bad array subscript" because you cannot access an associative array with an empty key.

Steps to Reproduce

  1. Call the action with profile_filename but without service_mesh:
- uses: layer5io/meshery-smp-action@master
  with:
    provider_token: ${{ secrets.PROVIDER_TOKEN }}
    platform: docker
    profile_name: test-profile
    profile_filename: test-config.yaml
    # service_mesh not provided
  1. The script enters the else branch (line 58) because perf_filename is set
  2. Line 61 crashes because $service_mesh is empty

Impact

This bug is causing the meshery/meshery scheduled e2e tests to fail continuously. The workflow at .github/workflows/mesheryctl-e2e.yaml calls this action without providing service_mesh, triggering this crash.

See: https://github.com/meshery/meshery/actions/workflows/mesheryctl-e2e.yaml

Proposed Fix

Wrap the adapter array access in a conditional check:

if [[ -n "$service_mesh" ]]; then
    shortName=$(echo ${adapters[$service_mesh]} | cut -d ':' -f1)
    shortName=${shortName#meshery-}
    if [[ -n "$shortName" ]]; then
        docker network connect bridge meshery_meshery-"$shortName"_1 2>/dev/null || true
        docker network connect minikube meshery_meshery-"$shortName"_1 2>/dev/null || true
    fi
fi

I have a PR ready to submit with this fix.

Environment

  • Action version: master branch
  • Triggered from: meshery/meshery scheduled e2e workflow

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions