Skip to content

BUG: _resolve_placeholders crashes with IndexError on positional format placeholders like {0} #154

@devteamaegis

Description

@devteamaegis

What breaks

`_resolve_placeholders` in `workflows/workflow_use/workflow/service.py` only catches `KeyError` when calling `str.format(**context)` on a string that contains placeholder syntax. When the string contains a positional format specifier such as `{0}` (common in copy-pasted JSON values, URL templates, or CSS strings), Python raises `IndexError: Replacement index 0 out of range for positional args tuple` instead of `KeyError`. This exception is not caught, so the workflow crashes entirely.

How to trigger

Any workflow step whose `value` (or any other string field) contains a numeric format specifier, for example:

```json
{ "type": "input", "value": "Query param: {0}" }
```

causes the crash at runtime during placeholder resolution.

Traceback

```
Traceback (most recent call last):
File "service.py", line 517, in _resolve_placeholders
formatted_data = data.format(**self.context)
IndexError: Replacement index 0 out of range for positional args tuple
```

Fix

Catch `(KeyError, IndexError)` instead of just `KeyError` in the `except` clause of `_resolve_placeholders`.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions