refactor(settings): apply the unset rule to optional string Literals too

Review follow-up. EMBEDDINGS_POOLING became Optional[Literal["cls", "mean"]],
but the group-base rule that maps "", "None" and whitespace to None only
matched Optional[str], so EMBEDDINGS_POOLING= in a .env file would have
failed validation. The rule now also covers an Optional Literal whose
choices are all strings, which lets the AUTH_TYPE validator drop its own
copy of that handling.
This commit is contained in:
arc53-machine committed 2026-09-17 11:51:28 +01:00
1 parent 5578039c19
commit 41135fc894
3 files changed
+20 -8

No files matched your search

+3 -3
View File
@@ -6,7 +6,7 @@ from typing import Literal, Optional
from pydantic import Field, field_validator, model_validator
from docsgpt.core.settings._shared import SettingsGroup, normalize_choice, normalize_secret
from docsgpt.core.settings._shared import SettingsGroup, normalize_choice
#: Settings an OIDC deployment cannot run without; checked when AUTH_TYPE=oidc.
@@ -88,8 +88,8 @@ class AuthSettings(SettingsGroup):
@field_validator("AUTH_TYPE", mode="before")
@classmethod
def _normalize_auth_type(cls, v):
# ``AUTH_TYPE=None`` and ``AUTH_TYPE=`` in .env both mean "no authentication".
return normalize_choice(normalize_secret(v))
# Unset spellings ("None", "") became None on the group base; this only case-folds a value.
return normalize_choice(v)
@model_validator(mode="after")
def _require_oidc_settings(self):