Skip to content
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

Trimmed trailing slash in URL provided to create Client API #15513

Merged
merged 4 commits into from
Sep 24, 2020

Conversation

shieldsjared
Copy link
Contributor

Summary

As described in this issue while attempting to utilize the MM Plugin Started Template, it was determined that including a trailing slash when calling model.NewAPIv4Client with a URL that includes a trailing slash, the resulting URL's become malformed (double-slash) and MM is unable to route the requests appropriately. Trimming a trailing slash prevents users from having to be too particular when specifying the URL of their target server.

Note that this fix does not correct if a user attempts to use a URL with multiple trailing-slashes (however, this should be a bit more obvious of an issue to the end-user if they incorrectly set the MM url with multiple trailing-slashes).

Ticket Link

Fixes: mattermost/mattermost-plugin-starter-template#115

Also, please see PR on that repository for discussion and agreed-upon path forward for resolution (included in this PR)

@lieut-data lieut-data added 2: Dev Review Requires review by a developer 3: QA Review Requires review by a QA tester. May occur at the same time as Dev Review labels Sep 16, 2020
Copy link
Member

@lieut-data lieut-data left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @shieldsjared! One comment below.

model/client4_test.go Outdated Show resolved Hide resolved
model/client4.go Outdated Show resolved Hide resolved
…eck api endpoint. Test case includes checks for expected (0), probable (1), and arbitrary (5) number of slashes to stress the implementation to ensure it wasnt built for a specific numbre of slashes
@shieldsjared
Copy link
Contributor Author

Changes implemented and ready for review again @lieut-data - Thanks!

Copy link
Contributor

@hanzei hanzei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@hanzei hanzei added this to the v5.28.0 milestone Sep 17, 2020
Copy link
Member

@lieut-data lieut-data left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet!

@mattermod mattermod removed the EETests label Sep 17, 2020
@lieut-data lieut-data removed the 2: Dev Review Requires review by a developer label Sep 17, 2020
@amyblais amyblais added the CherryPick/Approved Meant for the quality or patch release tracked in the milestone label Sep 17, 2020
@amyblais
Copy link
Member

@prapti Kind reminder to review for v5.28.

@prapti
Copy link

prapti commented Sep 21, 2020

Thanks @amyblais!
In test queue.

@hanzei
Copy link
Contributor

hanzei commented Sep 22, 2020

/update-branch

Copy link

@prapti prapti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Thank you @shieldsjared for this fix and thank you for noting that "this fix does not correct if a user attempts to use a URL with multiple trailing-slashes", that was helpful :)

@prapti prapti added 4: Reviews Complete All reviewers have approved the pull request and removed 3: QA Review Requires review by a QA tester. May occur at the same time as Dev Review labels Sep 23, 2020
@hanzei hanzei merged commit e726b04 into mattermost:master Sep 24, 2020
@mattermod
Copy link
Contributor

Cherry pick is scheduled.

mattermost-build pushed a commit to mattermost-build/mattermost that referenced this pull request Sep 24, 2020
@mattermod mattermod added CherryPick/Done Successfully cherry-picked to the quality or patch release tracked in the milestone and removed CherryPick/Approved Meant for the quality or patch release tracked in the milestone labels Sep 24, 2020
@amyblais amyblais added Changelog/Not Needed Does not require a changelog entry Docs/Not Needed Does not require documentation labels Sep 24, 2020
mattermod added a commit to mattermost-build/mattermost that referenced this pull request Sep 25, 2020
@shieldsjared shieldsjared deleted the MM_ClientApi_TrimTrailingSlash branch October 4, 2020 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4: Reviews Complete All reviewers have approved the pull request Changelog/Not Needed Does not require a changelog entry CherryPick/Done Successfully cherry-picked to the quality or patch release tracked in the milestone Docs/Not Needed Does not require documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Trailing slash on MM_SERVICESETTINGS_SITEURL causes non-obvious errors
6 participants