1
0

Compare commits

...

2 Commits

Author SHA1 Message Date
Andrew Morgan
ab2122b364 Allow coercing a str to a FilePath in MasConfigModel 2025-11-05 13:43:00 +00:00
Andrew Morgan
23c0c475da Print MASConfigModel validation error cause 2025-11-05 11:51:22 +00:00

View File

@@ -37,7 +37,8 @@ class MasConfigModel(ParseModel):
enabled: StrictBool = False
endpoint: AnyHttpUrl = AnyHttpUrl("http://localhost:8080")
secret: Optional[StrictStr] = Field(default=None)
secret_path: Optional[FilePath] = Field(default=None)
# We set `strict=False` to allow `str` instances.
secret_path: Optional[FilePath] = Field(default=None, strict=False)
@model_validator(mode="after")
def verify_secret(self) -> Self:
@@ -69,7 +70,7 @@ class MasConfig(Config):
parsed = MasConfigModel(**mas_config)
except ValidationError as e:
raise ConfigError(
"Could not validate Matrix Authentication Service configuration",
f"Could not validate Matrix Authentication Service configuration: {e.errors()[0]['msg']}",
path=("matrix_authentication_service",),
) from e