-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[#55382] add connection validation section #15894
[#55382] add connection validation section #15894
Conversation
370e37e
to
c97535a
Compare
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.
Nice one @Kharonus 🏆 I have a couple of 🟢 & 🟠 but nothing blocking. Shout if easier to chat/pair 🙂
modules/storages/app/components/storages/admin/sidebar/validation_result_component.html.erb
Outdated
Show resolved
Hide resolved
modules/storages/app/controllers/storages/admin/connection_validation_controller.rb
Show resolved
Hide resolved
modules/storages/app/components/storages/admin/sidebar_component.html.erb
Show resolved
Hide resolved
maybe_is_not_configured | ||
.or { tenant_id_wrong } | ||
.or { client_id_wrong } | ||
.or { client_secret_wrong } | ||
.or { drive_id_wrong } | ||
.or { request_failed_with_unknown_error } | ||
.or { drive_with_unexpected_content } | ||
.value_or(ConnectionValidation.new(type: :healthy, timestamp: Time.current, description: nil)) |
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.
🟢 The monads are a really nice touch, but I wonder if we can follow a positive naming scheme- the negation based naming can sometimes be confusing (at least to me)
maybe_is_not_configured | |
.or { tenant_id_wrong } | |
.or { client_id_wrong } | |
.or { client_secret_wrong } | |
.or { drive_id_wrong } | |
.or { request_failed_with_unknown_error } | |
.or { drive_with_unexpected_content } | |
.value_or(ConnectionValidation.new(type: :healthy, timestamp: Time.current, description: nil)) | |
maybe_storage_configured | |
.or { validate_tenant_id } | |
.or { validate_client_id } | |
.or { validate_client_secret } | |
.or { validate_drive_id } | |
.or { request_failed_with_unknown_error } | |
.or { drive_with_unexpected_content } | |
.value_or(ConnectionValidation.new(type: :healthy, timestamp: Time.current, description: nil)) |
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.
Ah, well, that is interesting. Especially due to the or
concatenation I naturally read negative namings. It seems more natural then the positive way.
See this imaginary monologue.
"So, I have this storage.... I suspect it to be invalid."
"Maybe the storage is not fully configured?"
"Well, apparently it is... so, is then tenant id wrong?"
"Hmm, not... what about the client id?"
"Or the client secret?"
"Anything of that? No? Then apparently you are valid."
Get what I am pointing at? :D validations are "positive" when they are "negative", hence finding a problem means, your validation was justified.
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.
Get what I am pointing at? :D validations are "positive" when they are "negative", hence finding a problem means, your validation was justified.
I see wym for sure, and perhaps ActiveModel::Validations are a great conventional example; they only push to errors
in the even "negative" event that there's a validation failure, otherwise they just return ?true.
Hence in your imaginany monologue 😄 mine would read like so:
"So I have this storage... I need to validate that everything is configured properly"
"Firstly, validated it is fully configured"
"Then, validate the tenant id is correct"
"Then, validate the client id is correct"
"Then, validate the client secret is correct"
"When there are invalid cases, collect them and display a unified response (similar to active_model_errors) to the user"
"When there are no errors, return- mark the storage connection as valid"
I reckon what's different with my monologue is that I presume we're collecting all errors- and displaying them once to the user, but AFAICT- we fail fast on the first error result? In which case that might be inconvenient if the user has to click the button multiple times because they are served one error at a time.
In which case, I wonder if just mixin in ActiveModel::Validations and writing these as validate statements would be more fitting albeit less "Monad-ish" 😄
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.
but AFAICT- we fail fast on the first error result?
Here's the trick, except for the missing/empty values, it is impossible to validate if the previous validation has failed. If the tenant id is wrong, we can't validate the Client ID/Secret, if the Client ID/Secret is wrong we can't validate the Drive ID.
In which case, I wonder if just mixin in ActiveModel::Validations and writing these as validate statements would be more fitting albeit less "Monad-ish" 😄
There are always more than one way to do things. A dry/validation
contract, ActiveModel::Validations
or a chain of assertions all could do the same thing.
- ActiveModel would be tied directly to an object (with certain assumptions).
Dry::Validation::Contract
would create an object just for validation of a hash/json that could be passed down after validation.- A chain of assertions (in this case using the Maybe/Option monad) makes explicit the validation process.
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.
Here's the trick, except for the missing/empty values, it is impossible to validate if the previous validation has failed. If the tenant id is wrong, we can't validate the Client ID/Secret, if the Client ID/Secret is wrong we can't validate the Drive ID.
Yes, and here we should design it, as the domain user story is telling us. And here, it was set, we do not show all errors. We do show the first error, that can happen. Hence, the implementation follows that story, and fails with the first error, not checking for the other validation rules.
...storages/app/views/storages/admin/connection_validation/validate_connection.turbo_stream.erb
Outdated
Show resolved
Hide resolved
modules/storages/spec/common/storages/peripherals/one_drive_connection_validator_spec.rb
Show resolved
Hide resolved
modules/storages/spec/common/storages/peripherals/one_drive_connection_validator_spec.rb
Show resolved
Hide resolved
modules/storages/spec/requests/storages/admin/connection_validation_spec.rb
Show resolved
Hide resolved
modules/storages/spec/requests/storages/admin/connection_validation_spec.rb
Show resolved
Hide resolved
- https://community.openproject.org/work_packages/55382 - added new controller for connection validation - added new component to sidebar
- enable sidebar for all one drive storages to show the connection validation
- have one health status section, containing both AMPF and connection validation
- use helper methods from OpTurbo::Streamable - add error codes to validation result
087beb9
to
aa732f7
Compare
…n-one-drive-storages
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.
Cheers Eric!
#55382
WAT?