fix: convert boolean string to boolean (#2284)

# What does this PR do?

Handles the case where the vllm config `tls_verify` is set to `false` or
`true`.

Closes: https://github.com/meta-llama/llama-stack/issues/2283

Signed-off-by: Sébastien Han <seb@redhat.com>
This commit is contained in:
Sébastien Han 2025-05-27 22:05:38 +02:00 committed by GitHub
parent a8f75d3897
commit 6ee319ae08
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -34,11 +34,16 @@ class VLLMInferenceAdapterConfig(BaseModel):
@classmethod @classmethod
def validate_tls_verify(cls, v): def validate_tls_verify(cls, v):
if isinstance(v, str): if isinstance(v, str):
cert_path = Path(v) # Check if it's a boolean string
if v.lower() in ("true", "false"):
return v.lower() == "true"
# Otherwise, treat it as a cert path
cert_path = Path(v).expanduser().resolve()
if not cert_path.exists(): if not cert_path.exists():
raise ValueError(f"TLS certificate file does not exist: {v}") raise ValueError(f"TLS certificate file does not exist: {v}")
if not cert_path.is_file(): if not cert_path.is_file():
raise ValueError(f"TLS certificate path is not a file: {v}") raise ValueError(f"TLS certificate path is not a file: {v}")
return v
return v return v
@classmethod @classmethod