[Frontend] Require cache_salt to be non-empty via schema (#50816)
Signed-off-by: DarkLight1337 <tlleungac@connect.ust.hk>
Cyrus Leung committed
Aug 3, 2026 at 14:51 UTC
b3f97dae24a8d73535feca70b1c75cf6db4737e1
5 files changed
+4
-51
vllm/entrypoints/openai/chat_completion/protocol.py
+1
-12
@@ -452,6 +452,7 @@ class ChatCompletionRequest(OpenAIBaseModel):
452
453
cache_salt: str | None = Field(
454
default=None,
455
+ min_length=1,
456
description=(
457
"If specified, the prefix cache will be salted with the provided "
458
"string to prevent an attacker to guess prompts in multi-user "
@@ -968,18 +969,6 @@ class ChatCompletionRequest(OpenAIBaseModel):
969
)
970
return data
971
971
- @model_validator(mode="before")
972
- @classmethod
973
- def check_cache_salt_support(cls, data):
974
- if data.get("cache_salt") is not None and (
975
- not isinstance(data["cache_salt"], str) or not data["cache_salt"]
976
- ):
977
- raise VLLMValidationError(
978
- "Parameter 'cache_salt' must be a non-empty string if provided.",
979
- parameter="cache_salt",
980
- )
981
- return data
982
-
972
@model_validator(mode="before")
973
@classmethod
974
def check_system_message_content_type(cls, data):
vllm/entrypoints/openai/completion/protocol.py
+1
-12
@@ -184,6 +184,7 @@ class CompletionRequest(OpenAIBaseModel):
184
185
cache_salt: str | None = Field(
186
default=None,
187
+ min_length=1,
188
description=(
189
"If specified, the prefix cache will be salted with the provided "
190
"string to prevent an attacker to guess prompts in multi-user "
@@ -575,18 +576,6 @@ class CompletionRequest(OpenAIBaseModel):
576
577
return data
578
578
- @model_validator(mode="before")
579
- @classmethod
580
- def check_cache_salt_support(cls, data):
581
- if data.get("cache_salt") is not None and (
582
- not isinstance(data["cache_salt"], str) or not data["cache_salt"]
583
- ):
584
- raise VLLMValidationError(
585
- "Parameter 'cache_salt' must be a non-empty string if provided.",
586
- parameter="cache_salt",
587
- )
588
- return data
589
-
579
580
class CompletionLogProbs(OpenAIBaseModel):
581
text_offset: list[int] = Field(default_factory=list)
vllm/entrypoints/openai/responses/protocol.py
+1
-12
@@ -243,6 +243,7 @@ class ResponsesRequest(OpenAIBaseModel):
243
)
244
cache_salt: str | None = Field(
245
default=None,
246
+ min_length=1,
247
description=(
248
"If specified, the prefix cache will be salted with the provided "
249
"string to prevent an attacker to guess prompts in multi-user "
@@ -476,18 +477,6 @@ class ResponsesRequest(OpenAIBaseModel):
477
)
478
return data
479
479
- @model_validator(mode="before")
480
- @classmethod
481
- def check_cache_salt_support(cls, data):
482
- if data.get("cache_salt") is not None and (
483
- not isinstance(data["cache_salt"], str) or not data["cache_salt"]
484
- ):
485
- raise VLLMValidationError(
486
- "Parameter 'cache_salt' must be a non-empty string if provided.",
487
- parameter="cache_salt",
488
- )
489
- return data
490
-
480
@model_validator(mode="before")
481
@classmethod
482
def input_item_parsing(cls, data):
vllm/entrypoints/pooling/base/protocol.py
-15
@@ -82,21 +82,6 @@ class PoolingBasicRequestMixin(OpenAIBaseModel):
82
)
83
# --8<-- [end:pooling-common-extra-params]
84
85
- @model_validator(mode="before")
86
- @classmethod
87
- def check_cache_salt_support(cls, data):
88
- if not isinstance(data, dict):
89
- return data
90
-
91
- if data.get("cache_salt") is not None and (
92
- not isinstance(data["cache_salt"], str) or not data["cache_salt"]
93
- ):
94
- raise VLLMValidationError(
95
- "Parameter 'cache_salt' must be a non-empty string if provided.",
96
- parameter="cache_salt",
97
- )
98
- return data
99
-
85
def _build_pooling_tok_params(
86
self,
87
model_config: ModelConfig,
vllm/entrypoints/scale_out/token_in_token_out/protocol.py
+1
@@ -113,6 +113,7 @@ class GenerateRequest(BaseModel):
113
stream_options: StreamOptions | None = None
114
cache_salt: str | None = Field(
115
default=None,
116
+ min_length=1,
117
description=(
118
"If specified, the prefix cache will be salted with the provided "
119
"string to prevent an attacker to guess prompts in multi-user "