Skip to content

Conversation

@nimarb
Copy link
Contributor

@nimarb nimarb commented Dec 4, 2025

Important

Adds prompt deletion feature with cache invalidation and identifies JSONDecodeError issue with 204 responses.

  • Behavior:
    • Adds delete_prompt() method in client.py to delete prompts or specific versions/labels, with cache invalidation.
    • Handles 204 No Content responses by catching JSONDecodeError, but this is a workaround.
  • Clients:
    • Implements delete() method in PromptsClient and AsyncPromptsClient in client.py.
  • Tests:
    • Adds tests in test_prompt.py to verify prompt deletion and cache invalidation.
  • Issue:
    • 204 No Content responses cause JSONDecodeError in client.py due to attempts to parse empty response body.

This description was created by Ellipsis for 1ca5a2d. You can customize this summary. It will automatically update as commits are pushed.


Disclaimer: Experimental PR review

Greptile Overview

Greptile Summary

Added delete_prompt() method to enable deletion of prompts or specific versions/labels from Langfuse, with automatic cache invalidation.

Key Changes:

  • Implemented delete() methods in both sync and async prompt clients
  • Added high-level delete_prompt() wrapper that handles cache invalidation
  • Includes comprehensive test coverage verifying both deletion and cache invalidation

Critical Issue Found:

  • The API client's delete methods will fail when the server returns 204 No Content (standard for DELETE operations) because the code attempts to parse an empty response body as JSON, which will raise a JSONDecodeError

Confidence Score: 1/5

  • This PR contains a critical bug that will cause runtime failures on successful deletions
  • The implementation has a logical error where 204 No Content responses will trigger JSONDecodeError since the code tries to parse an empty body. While a workaround exists in the high-level wrapper, it relies on catching the error rather than preventing it, making the implementation fragile
  • Pay close attention to langfuse/api/resources/prompts/client.py - both sync and async delete methods need fixing

Important Files Changed

File Analysis

Filename Score Overview
langfuse/api/resources/prompts/client.py 1/5 Added delete() method for sync/async clients, but 204 response handling will cause JSONDecodeError
langfuse/_client/client.py 3/5 Added delete_prompt() wrapper with cache invalidation and 204 error workaround
tests/test_prompt.py 4/5 Added comprehensive test for prompt deletion with cache invalidation verification

Sequence Diagram

sequenceDiagram
    participant User
    participant Langfuse
    participant PromptsClient
    participant API
    participant PromptCache

    User->>Langfuse: delete_prompt(name, label?, version?)
    Langfuse->>Langfuse: _url_encode(name)
    Langfuse->>PromptsClient: delete(prompt_name, label, version)
    PromptsClient->>API: DELETE /api/public/v2/prompts/{name}?label&version
    API-->>PromptsClient: 204 No Content
    PromptsClient-->>Langfuse: EmptyResponse (or ApiError)
    alt status_code == 204
        Langfuse->>Langfuse: Catch ApiError, pass
    else other error
        Langfuse-->>User: Raise exception
    end
    Langfuse->>PromptCache: invalidate(name)
    PromptCache->>PromptCache: Clear all cached entries for prompt
    Langfuse-->>User: None (success)
Loading

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.

4 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

@nimarb nimarb enabled auto-merge (squash) December 8, 2025 13:13
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.

3 participants