Fix URL encoding for prompt names with special characters #259
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue
When creating prompts with names containing special characters (like slashes, colons, or question marks) through the UI, the Python client fails to fetch them due to improper URL encoding. This causes 404 errors when the special characters are interpreted as path separators instead of being treated as part of the name.
Root Cause
The
quote()function fromurllib.parsewas being used without thesafe=''parameter, which meant certain characters (especially forward slashes) were not being encoded in the URL path.Solution
get_prompt_templateandaget_prompt_templatefunctions to usequote(prompt_name, safe='')to encode ALL special characters_resolve_workflow_idfunction for consistent behaviorTesting
Created test cases for different special characters:
/) → encoded as%2F:) → encoded as%3A?) → encoded as%3F#Closed: #254
This fix enables users to create and fetch prompts with hierarchical naming schemes like "feature1/resolve_problem_2" without running into 404 errors.