argoproj / argoproj/argo-workflows

`withParam` expanded step names with `.` in item key or value causes map nesting issues

Open
#10,602 4 comments 0 reactions 0 assignees View on GitHub
area/looping area/templating P3
Dominant language
Go
Stars
17k
Forks
3.7k
Avg merge
1d 20h
Merged PRs (30d)
138

Description

### Pre-requisites

- [X] I have double-checked my configuration
- [X] I can confirm the issues exists when I tested with `:latest`
- [ ] I'd like to contribute the fix myself (see [contributing guide](https://github.com/argoproj/argo-workflows/blob/master/docs/CONTRIBUTING.md))

### What happened/what you expected to happen?

When using `withParam`, the expanded step name includes keys and values from the item json object. These key and value
string can contain `.`. This causes issues with the environment map that's passed when evaluating expression. This is because the environment map splits strings on `.`.

### Example

expanded step name: `with-param-example(0:url:github.com)`

expected reference:
```
steps["with-param-example(0:url:github.com)"].status == "Blah"
```

actual reference:
```
steps["with-param-example(0:url:github"]["com)"].status == "Blah"
```

I encountered this problem when trying to work with hook expressions for `withParam` steps. For my use case, I was checking the status of the step for a hook (I would be able to figure out the expanded step name using the `item.Url` as it's unique).

Hook expression: `steps[filter(sprig.keys(steps), { {{ item.Url }} in # })].status == "Succeeded"`

However, this breaks due to splitting keys on `.` when crafting the environment map for evaluating, so additional work is needed to navigate the env map.

### Version

v3.4.1

### Paste a small workflow that reproduces the issue. We must be able to run the workflow; don't enter a workflows that uses private images.

```YAML
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: steps-with-param-
spec:
entrypoint: main
templates:
- name: main
steps:
- - name: use-with-param
template: whalesay
arguments:
parameters:
- name: message
value: "{{item.Url}}"
withItems:
- {"Url": "https://github2.com"}
- {"Url": "https://github1.com"}
hooks:
test:
expression: 'steps[filter(sprig.keys(steps), { {{ item.Url }} in # })].status == "Succeeded"'
template: whalesay
arguments:
parameters:
- name: message
value: "hook ran!"
- name: whalesay
inputs:
parameters:
- name: message
container:
image: docker/whalesay:latest
command: [cowsay]
args: ["{{inputs.parameters.message}}"]
```

### Logs from the workflow controller

```text
N/A
```

### Logs from in your workflow's wait container

```text
N/A
```

Contributor guide

Open the contributing guide

Research direction

Start by running the provided workflow reproduction and inspect the workflow controller's expression environment-map handling for expanded step names containing dots. Confirm that the full name remains a single key, so the expression resolves steps["with-param-example(0:url:github.com)"] rather than splitting at the dot; rerun the reproduction to verify the hook expression works.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, kubernetes
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.