mattermost / mattermost/mattermost-plugin-gitlab
ERROR: can't decrypt token unpad error. This could happen when incorrect encryption key is used
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 152
- Forks
- 97
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 8
Description
Hello, I was setting up the plugin and everything worked fine. Then I've accidentally started the Mattermost server instance and lost the whole configuration and now I am setting it up from the ground again.
I am guessing, that some settings have persisted in the database, since I am receiving following error:
```
{"level":"error","ts":1625153373.8097563,"caller":"mlog/sugar.go:25","msg":"can't decrypt token","plugin_id":"com.github.manland.mattermost-plugin-gitlab","err":"unpad error. This could happen when incorrect encryption key is used"}
```
I guess it is this line: https://github.com/mattermost/mattermost-plugin-gitlab/blob/bb1e4fb115fc44a58ec2a5419c1140c32ff76dea/server/plugin.go#L163
I have tried following:
1. uninstalling plugin & installing plugin
2. resetting all settingssettings in Pugins -> GitLab
3. removing all old webhooks in self-hosted GitLab
Now, the GitLab part is OK:

Problem is on the Mattermost side. Following "Unknown Error" is after `/gitlab me` or `/gitlab disconnect`:

```
mmctl version
mmctl v5.35.0 -- a2fb3f6d9bb3851fa52f692718a93403c99e32be
mmctl plugin list
WARNING: server version 5.36.1.5.36.1.f8c5c7e436d1d06ba4bbb0d689fe6931.false doesn't match mmctl version 5.35.0
Listing enabled plugins
com.github.manland.mattermost-plugin-gitlab: GitLab, Version: 1.3.0
```
Any ideas how can I update the encryption key in the Mattermost or mattermost-plugin-gitlab?
I guess, that after changing settings in `/opt/mattermost/config/config.json`:
```
{
"Plugins": {
"com.github.manland.mattermost-plugin-gitlab": {
"enableprivaterepo": true,
"encryptionkey": "secret-JYEvKxhnAzsDA",
"gitlabgroup": null,
"gitlaboauthclientid": "secret-3c1112b3d333093f72f164111f1042c6629cde1",
"gitlaboauthclientsecret": "secret-6e612216d6485998ed3378dc11fac81134",
"gitlaburl": "https://git.domain",
"webhooksecret": "secret-mOBHCPtws2cANGuf"
}
},
}
```
The database is not updated. Is there any way how to trigger it?
EDIT: Just asked a colleague who have not did have Mattermost GitLab plugin integration (`/gitlab connect`) and it is working for him. Therefore, there are probably some remedies for my original account, since when I am doing `/gitlab me` I am getting `Unknown Error` as was screenshoted above.
Is there a way how can I disconnect bot for my account? `/gitlab disconnect` yields the same problem.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at server/plugin.go#L163 and trace how the encryption key in config.json is used for the token involved in /gitlab me and /gitlab disconnect. Reproduce the failure for the affected account, then determine how persisted state and a changed key interact; done means the cause and a supported recovery path are identified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100