Skip to content

fix: URL-encode workflow names with special characters in _resolve_workflow_id#294

Open
patoo0x wants to merge 1 commit intoMagnivOrg:masterfrom
patoo0x:fix/url-encode-workflow-name-254
Open

fix: URL-encode workflow names with special characters in _resolve_workflow_id#294
patoo0x wants to merge 1 commit intoMagnivOrg:masterfrom
patoo0x:fix/url-encode-workflow-name-254

Conversation

@patoo0x
Copy link

@patoo0x patoo0x commented Feb 21, 2026

Problem

Fixes #254

When a workflow is created with a name containing special characters like slashes (e.g. team/my-workflow), calling it via the Python client fails because _resolve_workflow_id builds the lookup URL as:

{base_url}/workflows/{workflow_id_or_name}

The unencoded slash is interpreted by the server as a path separator, causing a 404 or wrong-resource lookup.

Root Cause

_resolve_workflow_id in promptlayer/utils.py interpolates workflow_id_or_name directly into the URL path without encoding:

# Before (line 245)
response = await client.get(f"{base_url}/workflows/{workflow_id_or_name}", headers=headers)

The prompt-templates endpoint already received this same fix (merged in PR #291). This PR closes the remaining gap for workflow name lookup.

Fix

# After
response = await client.get(f"{base_url}/workflows/{quote(str(workflow_id_or_name), safe=)}", headers=headers)

urllib.parse.quote(..., safe=) — already imported in utils.py — encodes ALL special characters so the workflow name is always transmitted as a single opaque path segment.

Tests

Added TestUrlEncodingInResolveWorkflowId to tests/test_get_prompt_template.py:

Test Description
test_resolve_workflow_id_encodes_slashes team/my-workflowteam%2Fmy-workflow in URL
test_resolve_workflow_id_encodes_special_chars org/project:v2@prod → all chars encoded
test_resolve_workflow_id_integer_unchanged Integer IDs bypass the HTTP call entirely

All 11 tests in test_get_prompt_template.py pass (pytest tests/test_get_prompt_template.py).

…rkflow_id

Fixes MagnivOrg#254

The _resolve_workflow_id() function builds a URL like:
  {base_url}/workflows/{workflow_id_or_name}

When workflow_id_or_name contains special characters such as slashes
(e.g. 'team/my-workflow'), the slash is treated as a URL path separator
by the server, resulting in a 404 or wrong-resource response.

Fix: apply urllib.parse.quote(str(workflow_id_or_name), safe='') to
encode ALL special characters before interpolating into the URL.

The prompt-templates endpoint already received this fix (via PR MagnivOrg#291).
This commit closes the remaining gap in _resolve_workflow_id.

Tests added to TestUrlEncodingInResolveWorkflowId:
- test_resolve_workflow_id_encodes_slashes
- test_resolve_workflow_id_encodes_special_chars
- test_resolve_workflow_id_integer_unchanged
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

Successfully merging this pull request may close these issues.

Client fails to fetch prompts with names containing slash

1 participant