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

Code Previews not working with private repos #522

Open
tuxity opened this issue Jan 5, 2022 · 11 comments
Open

Code Previews not working with private repos #522

tuxity opened this issue Jan 5, 2022 · 11 comments
Labels
Help Wanted Community help wanted Type/Question Further information is requested Up For Grabs Ready for help from the community. Removed when someone volunteers

Comments

@tuxity
Copy link

tuxity commented Jan 5, 2022

Hello,

I can't get code preview in any channels when I link a file from a private repo. I have no error messages when I set MM server to debug mode. It just send default Github public link metadata.

Mattermost Server team edition version 6.2.1
Github plugin 2.0.1
Code Previews enabled for public and private repositories in Github plugin configuration
Connected via /github connect private
Tested with a Dockerfile from a public and private repos

I tested reconnecting account to GH, disabling/enabling Code Preview

I don't know if I'm missing something, tell me if you need more information.

@tuxity tuxity changed the title Code Previews not working with private repos from Org Code Previews not working with private repos Jan 5, 2022
@hanzei hanzei self-assigned this Jan 7, 2022
@hanzei hanzei added the Type/Question Further information is requested label Jan 7, 2022
@hanzei
Copy link
Contributor

hanzei commented Jan 7, 2022

Hi @tuxity,

Did you enable code previews for public and private repositories in the plugins settings?

@tuxity
Copy link
Author

tuxity commented Jan 7, 2022

Yes it is enable.

@hanzei
Copy link
Contributor

hanzei commented Jan 7, 2022

To which options is the setting set?

@tuxity
Copy link
Author

tuxity commented Jan 7, 2022

to "Enable for public and private repositories. This might leak confidential code into public channels."

@hanzei
Copy link
Contributor

hanzei commented Jan 7, 2022

I can't reproduce the issue.

  1. Do you see any related error in the server logs?
  2. Is the repository you tested with part of a organisation?

@tuxity
Copy link
Author

tuxity commented Jan 7, 2022

I tried to put the server in debug mode and there is no error in logs
I also tested with a private repo from an organisation and also one of my personal private repo and not working.

I also tried to disable and enable the plugin again, the plugin is not restricted to an organisation

Should I try to reinstall the plugin ? I will have to resetup every subscriptions in channels ?

@hanzei
Copy link
Contributor

hanzei commented Jan 10, 2022

Just to double check: You created the permalink by selecting the lines of code in the UI and clicking on Copy permalink?
Screenshot from 2022-01-10 09-08-01

@tuxity
Copy link
Author

tuxity commented Jan 10, 2022

Haven't tried this type of link, I was checking with URL in browser like

https://github.com/mattermost/mattermost-plugin-github/blob/master/Makefile
https://github.com/mattermost/mattermost-plugin-github/blob/master/Makefile#L27
(but with private repo ofc)

When I use permalink it's working correctly indeed.
https://github.com/mattermost/mattermost-plugin-github/blob/1068fe3eb5bf57b7c7cba22a43cc9491137a109a/Makefile#L12

So maybe the plugin isn't supposed to parse this type of URL for private repo ? The only difference is the commit id after /blob/ instead of the branch name

All my coworkers in my team use the URL from browser directly to reference a file, commit, PR... and we only get
image

@hanzei
Copy link
Contributor

hanzei commented Jan 20, 2022

Yes, that is indeed the expected behavior currently.

// quick bailout if the commit hash is not proper.
if _, err := hex.DecodeString(r.permalinkInfo.commit); err != nil {
p.API.LogError("Bad git commit hash in permalink", "error", err.Error(), "hash", r.permalinkInfo.commit)
continue
}

But I'm wondering if the plugin should support links to branches and tags. On caveat is that the content might change in the future and it's hard to keep the message in sync. So it would be a snapshot of the content at the time the message is posted.

@agnivade Do you have thoughts on this ideas, as you originally implemented the feature?

@agnivade
Copy link
Member

This feature is primarily supposed to work with permalinks, not with regular links. The original implementation mainly mirrored GitHub's permalink preview implementation. And as you can see from above, GitHub will also only expand permalinks, not all kinds of links.

This usually applies to all kinds of permalink previews - they are tied to a single id/hash. And not something that can change. Otherwise, this becomes a link preview, not permalink preview. We could do that of course, but then we deviate from the usual accepted standard.

As a first step, I'd suggest to document this more prominently, and how to capture and share permalinks, not regular links.

And to clarify, this has no relation to the type of repo - public/private. It only expands permalinks.

@hanzei hanzei removed their assignment Mar 1, 2022
@hanzei hanzei added Help Wanted Community help wanted Up For Grabs Ready for help from the community. Removed when someone volunteers labels Mar 1, 2022
@hanzei
Copy link
Contributor

hanzei commented Mar 1, 2022

Made this a Help Wanted documentation ticket

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Help Wanted Community help wanted Type/Question Further information is requested Up For Grabs Ready for help from the community. Removed when someone volunteers
Projects
None yet
Development

No branches or pull requests

3 participants