fix(prompts): handle httpx encoding for prompt name in updates #1450
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.
Important
Fixes URL encoding for prompt names in
update_prompt()inclient.pyto ensure compatibility withhttpx0.28.0+.update_prompt()inclient.pyby settingis_url_param=Truein_url_encode().httpxversion 0.28.0 and above, preventing double-encoding issues.This description was created by
for 0efa273. You can customize this summary. It will automatically update as commits are pushed.
Disclaimer: Experimental PR review
Greptile Overview
Greptile Summary
Fixed double-encoding bug in
update_promptmethod by adding theis_url_param=Trueflag to the_url_encodecall. This ensures prompt names (especially those in folders with slashes) are correctly encoded when sent to the API.is_url_param=Trueparameter to_url_encode()call inupdate_promptmethoddataset_items.list()update_promptwas manually encoding path parameters while httpx would also encode themConfidence Score: 5/5
Important Files Changed
File Analysis
is_url_param=Trueflag to_url_encodecall inupdate_promptmethod to prevent double-encoding with httpx ≥0.28Sequence Diagram
sequenceDiagram participant Client as Langfuse Client participant URLEncode as _url_encode() participant API as prompt_version.update() participant HTTPX as httpx client participant Server as Langfuse API Client->>URLEncode: _url_encode(name, is_url_param=True) alt httpx >= 0.28.0 URLEncode-->>Client: name (unencoded) Note over URLEncode: Skip encoding, httpx will handle it else httpx < 0.28.0 URLEncode->>URLEncode: urllib.parse.quote(name, safe="") URLEncode-->>Client: encoded_name Note over URLEncode: Manual encoding for older httpx end Client->>API: update(name, version, new_labels) API->>HTTPX: PATCH /api/public/v2/prompts/{name}/versions/{version} Note over HTTPX: httpx >= 0.28 applies WHATWG-compliant encoding HTTPX->>Server: HTTP Request Server-->>HTTPX: Response HTTPX-->>API: Prompt object API-->>Client: updated_prompt