Skip to content

Conversation

@hassiebp
Copy link
Contributor

@hassiebp hassiebp commented Nov 24, 2025

Important

Fixes URL encoding for prompt names in update_prompt() in client.py to ensure compatibility with httpx 0.28.0+.

  • Behavior:
    • Fixes URL encoding for prompt names in update_prompt() in client.py by setting is_url_param=True in _url_encode().
    • Ensures compatibility with httpx version 0.28.0 and above, preventing double-encoding issues.

This description was created by Ellipsis 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_prompt method by adding the is_url_param=True flag to the _url_encode call. This ensures prompt names (especially those in folders with slashes) are correctly encoded when sent to the API.

  • Added is_url_param=True parameter to _url_encode() call in update_prompt method
  • Aligns with the existing pattern used in other methods like dataset_items.list()
  • Prevents double-encoding when httpx ≥0.28 handles URL encoding automatically
  • Fixes consistency issue where update_prompt was manually encoding path parameters while httpx would also encode them

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The change is a single-line fix that adds a missing parameter to prevent double-encoding, follows existing patterns in the codebase, and aligns with how other similar methods handle URL encoding for httpx path parameters
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
langfuse/_client/client.py 5/5 Added is_url_param=True flag to _url_encode call in update_prompt method to prevent double-encoding with httpx ≥0.28

Sequence 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
Loading

@hassiebp hassiebp enabled auto-merge (squash) November 24, 2025 10:31
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

@hassiebp hassiebp closed this Dec 1, 2025
auto-merge was automatically disabled December 1, 2025 17:16

Pull request was closed

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.

2 participants