1.142.0rc1 regression fix: Allow coercing a str to a FilePath in MasConfigModel (#19144)
This commit is contained in:
1
changelog.d/19144.bugfix
Normal file
1
changelog.d/19144.bugfix
Normal file
@@ -0,0 +1 @@
|
||||
Fix a bug introduced in 1.142.0rc1 where any attempt to configure `matrix_authentication_service.secret_path` would prevent the homeserver from starting up.
|
||||
@@ -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:
|
||||
|
||||
@@ -30,6 +30,13 @@ class ParseModel(BaseModel):
|
||||
|
||||
but otherwise uses Pydantic's default behaviour.
|
||||
|
||||
Strict mode can adversely affect some types of fields, and should be disabled
|
||||
for a field if:
|
||||
|
||||
- the field's type is a `Path` or `FilePath`. Strict mode will refuse to
|
||||
coerce from `str` (likely what the yaml parser will produce) to `FilePath`,
|
||||
raising a `ValidationError`.
|
||||
|
||||
For now, ignore unknown fields. In the future, we could change this so that unknown
|
||||
config values cause a ValidationError, provided the error messages are meaningful to
|
||||
server operators.
|
||||
|
||||
Reference in New Issue
Block a user