-
Notifications
You must be signed in to change notification settings - Fork 416
1.142.0rc1 regression fix: Allow coercing a str to a FilePath in MasConfigModel
#19144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Otherwise `MasConfigModel` would always fail to validate, as the yaml parser would not produce a `FilePath` instance.
| @@ -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. No newline at end of file | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How was this problem caught?
Can we be sure it doesn't happen elsewhere? (feels like no without manually auditing things or test coverage to stress these pieces)
When having a cursory look, only this stood out to me,
synapse/synapse/config/matrixrtc.py
Lines 44 to 45 in 6790312
| class MatrixRtcConfigModel(ParseModel): | |
| transports: list = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How was this problem caught?
I raised this after the CI for element-hq/ess-helm#853 started failing on RC3
| - 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`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This kinda feels like a bug with the pydantic.FilePath type 🤔. Of course it has to be parsed from a string. Feels like it should act like Annotated[StrictStr, AfterValidator(validate_file_path)]
May be worth finding existing issues tracking this or creating one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see both sides of the argument. On one hand, it would be a bit odd to allow coercion for one specific type (str -> FilePath) in strict mode. On the other, most people will be taking in paths as str types. There should be a simple way to validate that the file exists etc. (which is what people expect to do when setting the type of the field to FilePath).
So I agree that there's something either wrong/missing. I'll raise it as an issue in a bit while waiting for the release assets to build.
|
Failing CI tests are flake and are unrelated to this PR. |
Otherwise
MasConfigModelwould always fail to validate, as the yaml parser would not produce aFilePathinstance.Missed in #19071.
Pull Request Checklist
EventStoretoEventWorkerStore.".code blocks.