Skip to content

Commit 18f1d28

Browse files
1.142.0rc1 regression fix: Allow coercing a str to a FilePath in MasConfigModel (#19144)
1 parent 2fd8d88 commit 18f1d28

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

changelog.d/19144.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
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.

synapse/config/mas.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ class MasConfigModel(ParseModel):
3737
enabled: StrictBool = False
3838
endpoint: AnyHttpUrl = AnyHttpUrl("http://localhost:8080")
3939
secret: Optional[StrictStr] = Field(default=None)
40-
secret_path: Optional[FilePath] = Field(default=None)
40+
# We set `strict=False` to allow `str` instances.
41+
secret_path: Optional[FilePath] = Field(default=None, strict=False)
4142

4243
@model_validator(mode="after")
4344
def verify_secret(self) -> Self:

synapse/util/pydantic_models.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ class ParseModel(BaseModel):
3030
3131
but otherwise uses Pydantic's default behaviour.
3232
33+
Strict mode can adversely affect some types of fields, and should be disabled
34+
for a field if:
35+
36+
- the field's type is a `Path` or `FilePath`. Strict mode will refuse to
37+
coerce from `str` (likely what the yaml parser will produce) to `FilePath`,
38+
raising a `ValidationError`.
39+
3340
For now, ignore unknown fields. In the future, we could change this so that unknown
3441
config values cause a ValidationError, provided the error messages are meaningful to
3542
server operators.

0 commit comments

Comments
 (0)