-
Notifications
You must be signed in to change notification settings - Fork 16
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
Make URL validation optional #68
Comments
Ignorance. The original library checked for I wasn't aware of Having an option to disable it entirely could also work, but at first glance this looks like an API change would be needed. Do you happen to have any references for |
@atc0005 thank you for the swift reply. I'm not deep into MS Teams at all and also haven't seen any explicit URL schema definition so far. Actually I'm also not sure whether it makes sense to restrict the lib to some predefined patterns. But that's just my humble opinion of cause. So in the end I'm ok with adding my schema to the validation or/and skip validation entirely. |
Fair question/concern. The intent of the validation is to help prevent "odd" failure results when attempting to use the tool. If an invalid pattern can be (reliably) detected and reported early, this might save frustrating troubleshooting efforts later. I think I understand what you may be saying though: you believe that the validation should occur within the client code and not the library itself?
Sure. Feedback is appreciated. I'm just trying to see if there is a way to satisfy both concerns. I checked earlier and couldn't find mention of Are you using Teams and it's giving you something different, or perhaps using a dashboard somewhere that generates them in the pattern you shared? |
Yeah more or less like that. I mean you could even think of using a local mock endpoint for integration testing and that validation would make it impossible.
I just generated the web hook URL from the Teams channel connector menu. The company is a pretty compliancy driven organisation so it might be that some parts are not following the standardised Outlook universe. |
Good point. I'm certainly open to suggestions. I'd like to see some sort of validation remain to ensure that the webhook URL is in at least a usable format. An earlier implementation of the code applied both https://github.com/dasrick/go-teams-notify/blob/1f93e29ec9f60cb01ee83e66dc35871a6a63956b/send.go What jumps out as options:
I still consider myself fairly new to Go, so I suspect that there are likely other, better ways to handle this and I am personally open to those ideas. My main concern is not breaking the API or expectations for other consumers of the package. |
Maybe the best way of not breaking the API would be to add an optional flag to type teamsClient struct {
httpClient *http.Client
skipWebUrlValidation bool
}
func (c teamsClient) SkipWebUrlValidationOnSend(skip bool) {
c.skipWebUrlValidation = skip
}
// set skipWebUrlValidation = false by default
mstClient := goteamsnotify.NewClient()
// optionally disable URL validation
mstClient.SkipWebUrlValidationOnSend(true)
mstClient.Send(webhookUrl, msgCard) WDYT? |
I like it. Very clean and with minimal changes required. Would you like to submit a PR for this? If not, I can probably work this in later today or early tomorrow. |
Other tasks ran longer than expected today, so I'm out of time for dev work. I'll plan to work on this in the AM and cut a new release with the changes. If you'd like to submit a PR instead, please let me know. |
Thoughts:
While looking over the tests, I'm seeing some issues that may need to be worked through so I'll look at that after merging this. I'm optimistic that everything will be sorted for a new release this AM. |
I may be missing something, but if It looks like we'll have to add |
- Update example text to assume Go Modules use - Add example section, move existing example - Add example of disabling webhook URL prefix validation refs GH-68
- Update example text to assume Go Modules use - Add example section, move existing example - Add example of disabling webhook URL prefix validation refs GH-68
@odise Unless I missed something, all items related to this are now complete. Cutting a new |
- README - updates to better clarify webhook URL patterns - add HowTo section for fetching webhook URLs - Validation - Rework validation to short circuit validation instead of skipping only the prefix validation as before - this better matches the intended/requested behavior from GH-68 - Use fixed-string constant as an indicator that validation has been disabled instead of a known/valid prefix pattern (this might not matter now, but could avoid confusion if logging what webhook URL was provided by client code) refs GH-84
I just wonder why the URL schema for is so strict and limited to
outlook.office365.com
andoutlook.office.com
? I'm currently facing a use case with an URL schema likehttps://<corporate-name>.webhook.office.com
which prevents me from using the library. Could give me some background here? Thanks a bunch.The text was updated successfully, but these errors were encountered: