-
Notifications
You must be signed in to change notification settings - Fork 127
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
MM-50981 Remove usage of model.AppError #921
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #921 +/- ##
==========================================
- Coverage 31.01% 30.89% -0.13%
==========================================
Files 50 50
Lines 7389 7332 -57
==========================================
- Hits 2292 2265 -27
+ Misses 4911 4886 -25
+ Partials 186 181 -5
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
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.
Great changes and cleanup of the deprecated built-in go APIs too!
@srkgupta Heads up that there is a merge conflict. |
server/issue.go
Outdated
} | ||
|
||
if post != nil && len(post.FileIds) > 0 { | ||
go func() { | ||
conf := instance.Common().getConfig() | ||
for _, fileID := range post.FileIds { | ||
mattermostName, _, _, e := client.AddAttachment(p.API, created.ID, fileID, conf.maxAttachmentSize) | ||
mattermostName, _, _, e := client.AddAttachment(*p.client, created.ID, fileID, conf.maxAttachmentSize) |
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.
While we are here: Can we rename the error
to the standard err
?
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.
Thanks for taking over this huge effort 👍
plugin_store.go
was left untouched. Why is that the case? Can the code in there also get migrated?- Let's double-check that the code migration around the KV store is correct. There are some edge cases we need to be aware of. More details in the comments below ⬇️
server/kv.go
Outdated
} | ||
|
||
err := json.Unmarshal(data, v) | ||
err := store.plugin.client.KV.Get(key, &v) |
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.
Previously, v
was passed to json.Unmarshal
meaning it had to be an pointer. Why does a pointer to v
get passed now?
server/kv.go
Outdated
if appErr != nil { | ||
return "", errors.WithMessage(appErr, "failed to load one-time secret "+key) | ||
var secret string | ||
err := store.get(hashkey(prefixOneTimeSecret, key), secret) |
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.
That looks suspicious. The stored data is not in JSON format, but store.get
will try to unmarshal it. Are you sure this line works?
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 catch. Yes, this looks like the code was accidentally over-written. It should read:
err := store.plugin.client.KV.Get(hashkey(prefixOneTimeSecret, key), secret)
I will push a commit to fix this.
server/kv.go
Outdated
return nil, 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.
Previously, the code returned an error in this case. Why was it removed?
server/plugin_test.go
Outdated
Configuration: validConfiguration, | ||
CreatePostError: model.NewAppError("foo", "bar", nil, "", http.StatusInternalServerError), | ||
CreatePostError: model.NewAppError("foo", "bar", nil, "", http.StatusBadRequest), | ||
Request: httptest.NewRequest("POST", "/webhook?team=theteam&channel=thechannel&secret=thesecret", validRequestBody()), | ||
ExpectedStatusCode: http.StatusInternalServerError, | ||
ExpectedStatusCode: http.StatusBadRequest, |
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.
Why was there a behaviour change?
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.
Thanks for the detailed review @hanzei. Will be making the suggested changes shortly and request your re-review once its committed. |
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.
No issues found other than Ben's comments above 👍
Hi @hanzei I have made all the changes based on your feedback. Requesting your re-review on this. Thanks |
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.
Two nits, but the rest LGTM 👍
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.
🚀
@srkgupta Heads up that there are merge conflicts to resolve |
@DHaussermann this is ready to be QA'd, as it also has the code for mux.Router PR which was recently merged with master. |
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.
Smoke tested Jira
For the most part I saw no issue.
One problem I see on this branch is that authenticating to Jira server seems to no longer work. (no issues with Cloud authentication)
Steps:
-
Install a Jira server instance (mine is 9.5.0)
-
Run the
/jira connect
command -
On the oAuth complete page I get a 405 response
-The ngrok tunnel to Jira shows nothing after the 302 (the other 2 calls in the screenshot happened later and are unrelated)
@srkgupta unfortunately, because of a licensing issue on Jira server I was still working to resolve Friday, I did not confirm this was working on #923 and deffered testing until now so, I am unsure of which PR introduces the behavior.
Thanks @DHaussermann. I have fixed the issue now. This was again one of those cases, where the HTTP method wasn't clearly defined previously in the OAuth1 Complete endpoint. Please use the latest code and try again. |
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.
Tested and passes
I have spent some time smoke testing and see no more regressions
Tested against both Cloud and Serever
- Setup
- Authentication flow (browser and desktop)
- Issue creation and attachment
- Subscription and delivery
- Multiple instances connected
- Tested various commands for assign, view and transition etc..
LGTM!
Thanks @srkgupta!
Summary
Remove usage of model.AppError in JIRA plugin
Ticket Link
https://mattermost.atlassian.net/browse/MM-50981