litellm - ✅(Solved) Fix [Bug]: sync get_chat_completion_prompt in PromptManagementBase raises ValueError when prompt_id is None [1 pull requests, 2 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
BerriAI/litellm#25425Fetched 2026-04-10 03:41:11
View on GitHub
Comments
2
Participants
3
Timeline
6
Reactions
0
Timeline (top)
commented ×2labeled ×2closed ×1cross-referenced ×1

Error Message

  1. Observe the 500 error

Fix Action

Fixed

PR fix notes

PR #25449: fix(prompt_management): return passthrough when prompt_id is None in sync path

Description (problem / solution / changelog)

Relevant issues

Fixes #25425

What's the problem?

When prompt_id is None, the sync get_chat_completion_prompt() in PromptManagementBase raises a hard ValueError:

ValueError: prompt_id is required for Prompt Management Base class

This causes 500 errors when prompt management hooks are triggered without a prompt_id — for example, when vector_store_ids: [] is silently injected into model settings via the UI (see #25133), causing should_run_prompt_management_hooks() to return True.

The async counterpart async_get_chat_completion_prompt() handles this correctly by delegating to should_run_prompt_management(), which returns False for None prompt_id in all implementations (dotprompt, langfuse, generic, gitlab, etc.), causing a graceful passthrough.

Before (sync path — crashes):

if prompt_id is None:
    raise ValueError("prompt_id is required for Prompt Management Base class")

After (sync path — passthrough, matching async):

# Removed — should_run_prompt_management() already handles None prompt_id
if not self.should_run_prompt_management(...):
    return model, messages, non_default_params

Verification

Tested with a concrete PromptManagementBase subclass where should_run_prompt_management() returns False for None prompt_id (same as dotprompt, langfuse, generic, gitlab implementations):

  • Old code: ValueError: prompt_id is required for Prompt Management Base class
  • New code: returns (model, messages, non_default_params) unchanged — matching async behavior

Changes

  • Removed the ValueError guard in get_chat_completion_prompt() so the sync path uses the same should_run_prompt_management() check as the async path
  • Added 3 unit tests covering: sync None passthrough, async None passthrough, and sync with a valid prompt_id

Pre-Submission checklist

  • I have Added testing in the tests/test_litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem
  • I have requested a Greptile review by commenting @greptileai and received a Confidence Score of at least 4/5 before requesting a maintainer review

Type

🐛 Bug Fix

Changed files

  • litellm/integrations/prompt_management_base.py (modified, +0/-2)
  • tests/test_litellm/integrations/test_prompt_management_base.py (added, +162/-0)

Code Example

File "litellm/main.py", line 1321, in completion
  ) = litellm_logging_obj.get_chat_completion_prompt(...)
File "litellm/litellm_core_utils/litellm_logging.py", line 693, in get_chat_completion_prompt
  ) = custom_logger.get_chat_completion_prompt(...)
File "litellm/integrations/dotprompt/dotprompt_manager.py", line 209, in get_chat_completion_prompt
  return PromptManagementBase.get_chat_completion_prompt(...)
File "litellm/integrations/prompt_management_base.py", line 182, in get_chat_completion_prompt
  raise ValueError("prompt_id is required for Prompt Management Base class")
RAW_BUFFERClick to expand / collapse

Check for existing issues

  • I have searched the existing issues and checked that my issue is not a duplicate.

What happened?

All completion requests fail with 500 prompt_id is required for Prompt Management Base class when prompt management hooks are triggered without a prompt_id in the request.

In my case, the trigger was vector_store_ids: [] being silently injected into model settings when editing a model via the UI (related: [#25133]). This empty array causes should_run_prompt_management_hooks() to return True (via the non_default_params check in all_litellm_params), which invokes the prompt management callback chain — even though no prompt management is intended.

The core bug is in PromptManagementBase.get_chat_completion_prompt(): the sync implementation raises a hard ValueError when prompt_id is None, while the async counterpart async_get_chat_completion_prompt() handles this gracefully by returning the original parameters unchanged.

Expected behavior

When prompt_id is None, get_chat_completion_prompt() should return (model, messages, non_default_params) unchanged — identical to the async variant's behavior.

If this is indeed a bug, I can provide the PR to fix it.

Steps to Reproduce

  1. Start LiteLLM proxy with a model and a prompt configured (dotprompt)
  2. Edit any model via the UI (this injects vector_store_ids: [] into model settings — see [#25133](https://github.com/BerriAI/litellm/pull/25133))
  3. Make a normal /v1/chat/completions or /v1/responses request without prompt_id
  4. Observe the 500 error

Relevant log output

File "litellm/main.py", line 1321, in completion
  ) = litellm_logging_obj.get_chat_completion_prompt(...)
File "litellm/litellm_core_utils/litellm_logging.py", line 693, in get_chat_completion_prompt
  ) = custom_logger.get_chat_completion_prompt(...)
File "litellm/integrations/dotprompt/dotprompt_manager.py", line 209, in get_chat_completion_prompt
  return PromptManagementBase.get_chat_completion_prompt(...)
File "litellm/integrations/prompt_management_base.py", line 182, in get_chat_completion_prompt
  raise ValueError("prompt_id is required for Prompt Management Base class")

What part of LiteLLM is this about?

Proxy

What LiteLLM version are you on ?

v1.82.3

Twitter / LinkedIn details

No response

extent analysis

TL;DR

The get_chat_completion_prompt() function in PromptManagementBase should be modified to handle None prompt_id values without raising a ValueError, similar to its async counterpart.

Guidance

  • Review the implementation of get_chat_completion_prompt() in PromptManagementBase to ensure it handles None prompt_id values correctly.
  • Compare the sync and async implementations to identify the differences in handling prompt_id as None.
  • Consider updating the get_chat_completion_prompt() function to return the original parameters unchanged when prompt_id is None, as in the async variant.
  • Verify the fix by reproducing the issue with the modified code and checking that the 500 error is no longer raised.

Example

def get_chat_completion_prompt(self, model, messages, non_default_params):
    if self.prompt_id is None:
        # Return original parameters unchanged, as in async variant
        return model, messages, non_default_params
    # Existing implementation for non-None prompt_id

Notes

The provided log output and code references suggest that the issue is specific to the PromptManagementBase class and its handling of None prompt_id values. The fix should focus on updating this class to handle such cases correctly.

Recommendation

Apply workaround: Modify the get_chat_completion_prompt() function in PromptManagementBase to handle None prompt_id values without raising a ValueError, as described in the guidance. This change should resolve the 500 error issue when prompt_id is not provided.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

litellm - ✅(Solved) Fix [Bug]: sync get_chat_completion_prompt in PromptManagementBase raises ValueError when prompt_id is None [1 pull requests, 2 comments, 3 participants]