Giter VIP home page Giter VIP logo

gitlab's Introduction

gitlab's People

Contributors

apexo avatar bradtgmurray avatar cmuller avatar deepbluev7 avatar felix avatar grenadingue avatar l0ric0 avatar pheerai avatar sumpfralle avatar tulir avatar turt2live avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gitlab's Issues

Send raw webhook data to Matrix

It would probably be useful to get the raw data into Matrix. It should be put under an event type such as xyz.maubot.gitlab.webhook.

Migration from old GitLab bot

At least the database needs to be converted (old JSON file to new database). If we add per-room/webhook secrets in #28, that also needs some migrating

Send job events as edits to pipeline event messages

Currently job events are sent as separate messages, but really we should only have one announcement per pipeline and edit that each time a job is updated.

This probably involves storing the pipeline state somewhere so that we can regenerate the message when editing. I think the best solution would be to cache the pipeline data in memory and also send it in the Matrix event. If the bot is restarted during a pipeline, the data can be loaded from the event. The event ID is already stored in the db.

Use details tag for (long) issue descriptions

Some reporters file issues with very detailed descriptions (which is great!). That means a very long message gets sent to rooms with the bot, and it can break the flow of the conversation. Using a <details> tag to collapse the content would be welcome.

Fallback Links For Clients Without HTML support

Currently, the bot sends links in formatted_body, but clients that use body have no link, so users must manually navigate to events. A good fallback could be to append : <link here without brackets> to the end of messages.

Deployment instructions for Docker

The Dockerfile and its usage are currently unexplained in this repository. For system operators who wish to deminify the single point of failure in the bot ecosystem at t2bot.io, it would be a useful addition to this codebase to reflect upon the steps to get it running in written form.

Ideally this could also help to solve #15 by pushing this new content there.

Migrate away from python-gitlab

python-gitlab is not asyncio. Probably easiest to just write the necessary API calls manually into a library file like gitlab_hook.py is for webhooks.

T2B_ALIAS_UNKNOWN_ERROR

I'm not sure if that's a proper place to adk for support but if not, please forgive me and close the issue.

  1. I have invited bot to my channel (#prismo:matrix.org)
  2. I have created a webhook for my gitlab project and pointed it to https://t2bot.io/gitlab/webhooks?room=!IadFDmzRTSlgzQTZHj:matrix.org (that's the original ID of my channel)

When trying to send a test event through gitlab UI, gitlab gives me:

Hook executed successfully but returned HTTP 404 {"statusCode"=>404, "success"=>false, "error"=>"<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<title>Error</title>\n</head>\n<body>\n<pre>Cannot POST /gitlab/webhooks</pre>\n</body>\n</html>\n", "errcode"=>"T2B_ALIAS_UNKNOWN_ERROR"}

Is there anything obvious i've done wrong in here? Thanks in advance!

Bad English message "approveded" in Merge request events

Hello,

When selecting "Merge request events" in the Gitlab webhooks list, maubot gitlab is not formatting the right message. It tries to make a doubled past tense of "approved" and so we can see a message like:

[group / repo] User approveded merge request "description..."

This is due to the past_tense function in gitlab_matrix/gitlab_hook.py.

"Index out of range" when trying to add webhook

Hi there,

I have been trying to add a webhook to the bot after successfully authenticating it,
but I keep getting the same error message:

!gitlab webhook add mygroup/some-repo

...

  File "/data/plugins/xyz.maubot.gitlab-v0.2.0.mbp/gitlab_matrix/util/arguments.py", line 55, in match
    return rest[0], repo
IndexError: string index out of range

Now I don't know python well enough, but is it possible that empty string "" does not have a [0] index?

So the error may come from this line, where "rest" is assigned ""?

Please correct me if I'm wrong :)

Pushing a rebase yields very large messages

Hi!

I've been using this bot for a free software project (Whisperfish) for a while now. An annoyance I have, is when I rebase a branch against master, and then force-push. It yields messages like this

image

... where in fact only the last commit is "relevant" for the merge request, all the other commits are on master branch. It would be nice if somehow the GitLab bot notes that it's a force push with existing commits, and writes its notice like the GitHub bot does it:

image

FWIW, the bot should be receiving merge request events, but I don't think it currently handles them.

Don't remove multiple lines from commit message

I like to format my commit messages on multiple lines and currently the bot will only output the first line and only the first 80 characters of that line.

I would like to get the full message in there if possible. The whole point of the bot was so management in my company could see work being done and see the full messages without needing to go to gitlab to check it.

Merge train job events don't get matched

With Whisperfish, we're using merge trains and merged result tests. Instead of running the commit of a merge request on its own, Gitlab makes a merge commit with the target branch, then runs the CI on that.

This results in job events that cannot be correlated to the commits, and as such the very cool reaction bubbles don't appear for merge requests. They still appear for master branch commits.

image

image

image

If I can give you any information to help, I'd gladly supply it. Feel free to come say hi in #whisperfish:rubdos.be . That channel uses the t2bot.io instance and the unfiltered Gitlab group runner on https://gitlab.com/whisperfish (mainly the whisperfish repo)

Log:

[2022-04-09 19:11:02,073] [[email protected]] Accepted processing of Merge Request Hook
[2022-04-09 19:11:02,073] [[email protected]] 127.0.0.1 "POST /_matrix/maubot/plugin/gitlab/webhooks 202 199 in 0.001s"
[2022-04-09 19:11:03,904] [[email protected]] Accepted processing of Job Hook
[2022-04-09 19:11:03,905] [[email protected]] 127.0.0.1 "POST /_matrix/maubot/plugin/gitlab/webhooks 202 199 in 0.001s"
[2022-04-09 19:11:03,906] [[email protected]] No message found to react to push push-13453292-1d7ac8a7fe32ec10a77a072cc8e6576a5466034b-refs/merge-requests/246/merge
[2022-04-09 19:11:03,914] [[email protected]] Accepted processing of Job Hook
[2022-04-09 19:11:03,914] [[email protected]] 127.0.0.1 "POST /_matrix/maubot/plugin/gitlab/webhooks 202 199 in 0.001s"
[2022-04-09 19:11:03,915] [[email protected]] No message found to react to push push-13453292-1d7ac8a7fe32ec10a77a072cc8e6576a5466034b-refs/merge-requests/246/merge
[2022-04-09 19:11:03,926] [[email protected]] Accepted processing of Job Hook
[2022-04-09 19:11:03,927] [[email protected]] 127.0.0.1 "POST /_matrix/maubot/plugin/gitlab/webhooks 202 199 in 0.001s"
[2022-04-09 19:11:03,928] [[email protected]] No message found to react to push push-13453292-1d7ac8a7fe32ec10a77a072cc8e6576a5466034b-refs/merge-requests/246/merge
[2022-04-09 19:11:03,931] [[email protected]] Accepted processing of Job Hook
[2022-04-09 19:11:03,931] [[email protected]] 127.0.0.1 "POST /_matrix/maubot/plugin/gitlab/webhooks 202 199 in 0.0s"
[2022-04-09 19:11:03,932] [[email protected]] No message found to react to push push-13453292-1d7ac8a7fe32ec10a77a072cc8e6576a5466034b-refs/merge-requests/246/merge
[2022-04-09 19:11:03,939] [[email protected]] Accepted processing of Job Hook
[2022-04-09 19:11:03,939] [[email protected]] 127.0.0.1 "POST /_matrix/maubot/plugin/gitlab/webhooks 202 199 in 0.0s"
[2022-04-09 19:11:03,940] [[email protected]] No message found to react to push push-13453292-1d7ac8a7fe32ec10a77a072cc8e6576a5466034b-refs/merge-requests/246/merge
[2022-04-09 19:11:03,942] [[email protected]] Accepted processing of Job Hook
[2022-04-09 19:11:03,943] [[email protected]] 127.0.0.1 "POST /_matrix/maubot/plugin/gitlab/webhooks 202 199 in 0.001s"
[2022-04-09 19:11:03,944] [[email protected]] No message found to react to push push-13453292-1d7ac8a7fe32ec10a77a072cc8e6576a5466034b-refs/merge-requests/246/merge
[2022-04-09 19:11:03,946] [[email protected]] Accepted processing of Job Hook
[2022-04-09 19:11:03,947] [[email protected]] 127.0.0.1 "POST /_matrix/maubot/plugin/gitlab/webhooks 202 199 in 0.0s"
[2022-04-09 19:11:03,947] [[email protected]] No message found to react to push push-13453292-1d7ac8a7fe32ec10a77a072cc8e6576a5466034b-refs/merge-requests/246/merge
[2022-04-09 19:11:03,950] [[email protected]] Accepted processing of Job Hook
[2022-04-09 19:11:03,950] [[email protected]] 127.0.0.1 "POST /_matrix/maubot/plugin/gitlab/webhooks 202 199 in 0.001s"
[2022-04-09 19:11:03,951] [[email protected]] No message found to react to push push-13453292-1d7ac8a7fe32ec10a77a072cc8e6576a5466034b-refs/merge-requests/246/merge
[2022-04-09 19:11:03,952] [[email protected]] Accepted processing of Job Hook
[2022-04-09 19:11:03,952] [[email protected]] 127.0.0.1 "POST /_matrix/maubot/plugin/gitlab/webhooks 202 199 in 0.001s"
[2022-04-09 19:11:03,954] [[email protected]] No message found to react to push push-13453292-1d7ac8a7fe32ec10a77a072cc8e6576a5466034b-refs/merge-requests/246/merge
[2022-04-09 19:11:03,956] [[email protected]] Accepted processing of Job Hook
[2022-04-09 19:11:03,957] [[email protected]] 127.0.0.1 "POST /_matrix/maubot/plugin/gitlab/webhooks 202 199 in 0.002s"
[2022-04-09 19:11:03,958] [[email protected]] No message found to react to push push-13453292-1d7ac8a7fe32ec10a77a072cc8e6576a5466034b-refs/merge-requests/246/merge
[2022-04-09 19:11:03,961] [[email protected]] Accepted processing of Job Hook
[2022-04-09 19:11:03,961] [[email protected]] 127.0.0.1 "POST /_matrix/maubot/plugin/gitlab/webhooks 202 199 in 0.001s"
[2022-04-09 19:11:03,963] [[email protected]] No message found to react to push push-13453292-1d7ac8a7fe32ec10a77a072cc8e6576a5466034b-refs/merge-requests/246/merge

"webhook add" only allows either URL or repository (not both)

Currently the following command is rejected with a syntax error:

!gitlab webhook add SOME_ALIAS REPOSITORY/PATH/

The error message is the following:

Usage: !webhook add [server URL or alias] [repository]

The error message is confusing, since it seems to allow to specify a server alias (or URL) followed by the repository.
But in fact it seems to allow only one of these two optional arguments.

Thus the following should be more appropriate:

Usage: !webhook add [server URL or alias | repository]

Of course it would be even better to allow both a URL and a repository. Maybe keyword-based assignments (e.g. server=foo repo=something/) could make this possible.

Doesn't seem to work with multiple accounts

When I try to close an issue, while I am connected to 2 accounts (nheko.im and gitlab.com), the command throws various exceptions in my logs and gives me neither feedback nor does it do anything:

If I don't provide an account I get the following exception:

[2021-06-23 18:32:15,505] [[email protected].@gitlab:nheko.im] Failed to run handler
Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/sqlalchemy/orm/query.py", line 3490, in one
    ret = self.one_or_none()
  File "/usr/lib/python3.8/site-packages/sqlalchemy/orm/query.py", line 3467, in one_or_none
    raise orm_exc.MultipleResultsFound(
sqlalchemy.orm.exc.MultipleResultsFound: Multiple rows were found for one_or_none()

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/mautrix/client/syncer.py", line 200, in _catch_errors
    await handler(data)
  File "/usr/lib/python3.8/site-packages/maubot/handlers/command.py", line 108, in __call__
    ok, res = await self.__call_subcommand__(evt, call_args, remaining_val)
  File "/usr/lib/python3.8/site-packages/maubot/handlers/command.py", line 128, in __call_subcommand__
    return True, await subcommand(evt, _existing_args=call_args,
  File "/usr/lib/python3.8/site-packages/maubot/handlers/command.py", line 108, in __call__
    ok, res = await self.__call_subcommand__(evt, call_args, remaining_val)
  File "/usr/lib/python3.8/site-packages/maubot/handlers/command.py", line 128, in __call_subcommand__
    return True, await subcommand(evt, _existing_args=call_args,
  File "/usr/lib/python3.8/site-packages/maubot/handlers/command.py", line 104, in __call__
    ok, remaining_val = await self.__parse_args__(evt, call_args, remaining_val)
  File "/usr/lib/python3.8/site-packages/maubot/handlers/command.py", line 136, in __parse_args__
    remaining_val, call_args[arg.name] = arg.match(remaining_val.strip(), evt=evt,
  File "/var/lib/maubot/plugins/xyz.maubot.gitlab-v0.1.1.mbp/gitlab_matrix/util/arguments.py", line 41, in match
    return val, instance.bot.db.get_login(evt.sender)
  File "/var/lib/maubot/plugins/xyz.maubot.gitlab-v0.1.1.mbp/gitlab_matrix/db.py", line 160, in get_login
    row = (s.query(Token)
  File "/usr/lib/python3.8/site-packages/sqlalchemy/orm/query.py", line 3492, in one
    util.raise_(
  File "/usr/lib/python3.8/site-packages/sqlalchemy/util/compat.py", line 182, in raise_
    raise exception
sqlalchemy.orm.exc.MultipleResultsFound: Multiple rows were found for one()

If I provide the server in the command, I get the following error:

[2021-06-23 18:41:22,210] [[email protected].@gitlab:nheko.im] Failed to run handler  
Traceback (most recent call last):                                                                                     
  File "/usr/lib/python3.8/site-packages/mautrix/client/syncer.py", line 200, in _catch_errors                         
    await handler(data)                                                                                                
  File "/usr/lib/python3.8/site-packages/maubot/handlers/command.py", line 108, in __call__
    ok, res = await self.__call_subcommand__(evt, call_args, remaining_val)         
  File "/usr/lib/python3.8/site-packages/maubot/handlers/command.py", line 128, in __call_subcommand__
    return True, await subcommand(evt, _existing_args=call_args,
  File "/usr/lib/python3.8/site-packages/maubot/handlers/command.py", line 108, in __call__
    ok, res = await self.__call_subcommand__(evt, call_args, remaining_val)
  File "/usr/lib/python3.8/site-packages/maubot/handlers/command.py", line 128, in __call_subcommand__
    return True, await subcommand(evt, _existing_args=call_args,
  File "/usr/lib/python3.8/site-packages/maubot/handlers/command.py", line 104, in __call__
    ok, remaining_val = await self.__parse_args__(evt, call_args, remaining_val)
  File "/usr/lib/python3.8/site-packages/maubot/handlers/command.py", line 136, in __parse_args__
    remaining_val, call_args[arg.name] = arg.match(remaining_val.strip(), evt=evt,
  File "/var/lib/maubot/plugins/xyz.maubot.gitlab-v0.1.1.mbp/gitlab_matrix/util/arguments.py", line 40, in match           return " ".join(vals[1:]), instance.bot.db.get_login(evt.sender, url_alias=val[0])                                 
  File "/var/lib/maubot/plugins/xyz.maubot.gitlab-v0.1.1.mbp/gitlab_matrix/db.py", line 154, in get_login              
    row = (s.query(Token)
  File "/usr/lib/python3.8/site-packages/sqlalchemy/orm/query.py", line 3500, in one
    raise orm_exc.NoResultFound("No row was found for one()")
sqlalchemy.orm.exc.NoResultFound: No row was found for one()

I would like one of the command versions to work and best case even set a default instance per room :3

Cannot run docker

I've tried to follow the readme and issues/chat and cannot seem to start docker:

'''
# matrix at chat.mySecondLevelDomain.com in /opt/gitlab on git:master ● [16:32:59]
→ ls -la
total 120
drwxr-xr-x 4 root root 4096 Oct 23 14:49 .
drwxr-xr-x 3 root root 4096 Oct 23 09:52 ..
-rw-r--r-- 1 root root 1344 Oct 23 09:52 command-handler.go
-rw-r--r-- 1 root root 12336 Oct 23 09:52 commands.go
-rw-r--r-- 1 root root 1723 Oct 23 09:52 config.go
-rw-r--r-- 1 root root 315 Oct 23 09:55 config.json
-rw-r--r-- 1 root root 636 Oct 23 09:52 Dockerfile
-rw-r--r-- 1 root root 274 Oct 23 09:52 example-config.json
drwxr-xr-x 8 root root 4096 Oct 23 09:52 .git
-rw-r--r-- 1 root root 24 Oct 23 09:52 .gitignore
-rw-r--r-- 1 root root 2089 Oct 23 09:52 gitlab-auth.go
-rw-r--r-- 1 root root 8185 Oct 23 09:52 gitlab-webhook.go
-rw-r--r-- 1 root root 3062 Oct 23 09:52 Gopkg.lock
-rw-r--r-- 1 root root 952 Oct 23 09:52 Gopkg.toml
-rw-r--r-- 1 root root 32472 Oct 23 09:52 LICENSE
-rw-r--r-- 1 root root 2479 Oct 23 09:52 matrix.go
-rw-r--r-- 1 root root 1731 Oct 23 09:52 maulabbot.go
-rw-r--r-- 1 root root 2039 Oct 23 09:52 README.md
drwxr-xr-x 7 root root 4096 Oct 23 09:52 vendor

# matrix at chat.mySecondLevelDomain.com in /opt/gitlab on git:master ● [16:33:05]
→ cat config.json
{
"webhook": {
"listen": ":29313",
"path": "/webhooks",
"secret": "<reg_shared_secret_from_homeserver.yaml>"
},
"gitlab": {
"domain": "https://gitlab.org"
},
"matrix": {
"homeserver": "https://matrix.mySecondLevelDomain.com",
"username": "",
"password": ""
},
"options": {
"irc-compatibility": false
}
}

# matrix at chat.mySecondLevelDomain.com in /opt/gitlab on git:master ● [16:33:13]
→ sudo docker pull docker.io/maubot/gitlab:latest
latest: Pulling from maubot/gitlab
Digest: sha256:8b9de2a26819f30888e15e760f67f7f92e4e1b2d2ecf42f4941b4680666a0ec3
Status: Image is up to date for maubot/gitlab:latest

# matrix at chat.mySecondLevelDomain.com in /opt/gitlab on git:master ● [16:33:25]
→ sudo docker run --restart unless-stopped --name=gitlab --expose 29313 -v pwd:/etc/maulabbot:z docker.io/maubot/gitlab:latest
panic: Missing parameter: password

goroutine 1 [running]:
main.startMatrix(0x7ffe804dcf4d)
/go/src/maubot.xyz/gitlab/matrix.go:34 +0x6aa
main.main()
/go/src/maubot.xyz/gitlab/maulabbot.go:52 +0x1ba

# matrix at chat..com in /opt/gitlab on git:master ● [16:33:39]

'''
On the same server I have matrix running, riot and dimension (dimension is in a docker).
The gitlabbot container seem to be in a constant restart state:

'''
# matrix at chat.mySecondLevelDomain.com in /opt/gitlab on git:master ● [16:40:17]
→ sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1937f32bfc7e maubot/gitlab:latest "/usr/bin/maulabbot …" 6 minutes ago Restarting (2) 56 seconds ago gitlab
f516f3d6f5ee turt2live/matrix-dimension "/bin/bash" 9 days ago Up 4 days 127.0.0.1:8184->8184/tcp dimension

# matrix at chat.mySecondLevelDomain.com in /opt/gitlab on git:master ● [16:40:26]
→ netstat -plntu
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:8008 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:44841 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:8184 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:2209 0.0.0.0:* LISTEN -
tcp6 0 0 :::80 :::* LISTEN -
tcp6 0 0 :::8090 :::* LISTEN -
tcp6 0 0 :::443 :::* LISTEN -
tcp6 0 0 :::2209 :::* LISTEN -
udp 0 0 127.0.0.53:53 0.0.0.0:* -

# matrix at chat.mySecondLevelDomain.com in /opt/gitlab on git:master ● [16:40:44]

'''

Did I do something wrong here? Do I miss anything?

failed to handle merge request comment event

happens only when you comment merge request.

or is it bug in https://github.com/tulir/mautrix-python?

Traceback (most recent call last):
  File "/home/maubot/env/lib/python3.7/site-packages/mautrix/client/api/types/util/serializable_attrs.py", line 109, in _dict_to_attrs
    obj = attrs_type(**new_items)
TypeError: __init__() missing 3 required positional arguments: 'position', 'locked_at', and 'assignee'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/maubot/env/plugins/xyz.maubot.gitlab-v0.1.0.mbp/gitlab_matrix/bot.py", line 121, in process_hook
    evt = EventParse[req.headers["X-Gitlab-Event"]].deserialize(body)
  File "/home/maubot/env/lib/python3.7/site-packages/mautrix/client/api/types/util/serializable_attrs.py", line 264, in deserialize
    return _dict_to_attrs(cls, data)
  File "/home/maubot/env/lib/python3.7/site-packages/mautrix/client/api/types/util/serializable_attrs.py", line 105, in _dict_to_attrs
    field.metadata.get("ignore_errors", False))
  File "/home/maubot/env/lib/python3.7/site-packages/mautrix/client/api/types/util/serializable_attrs.py", line 124, in _try_deserialize
    return _deserialize(cls, value, default)
  File "/home/maubot/env/lib/python3.7/site-packages/mautrix/client/api/types/util/serializable_attrs.py", line 166, in _deserialize
    return _deserialize(cls.__args__[0], value, default)
  File "/home/maubot/env/lib/python3.7/site-packages/mautrix/client/api/types/util/serializable_attrs.py", line 161, in _deserialize
    return _dict_to_attrs(cls, value, default, default_if_empty=True)
  File "/home/maubot/env/lib/python3.7/site-packages/mautrix/client/api/types/util/serializable_attrs.py", line 115, in _dict_to_attrs
    raise SerializerError("Unknown serialization error") from e
mautrix.client.api.types.util.serializable.SerializerError: Unknown serialization error

Panic: interface{} is nil, not string

2018/07/15 23:51:19 INFO: Webhook received
2018/07/15 23:51:19 INFO: Parsing Payload...
2018/07/15 23:51:19 INFO: Checking secret
panic: interface conversion: interface {} is nil, not string

goroutine 7 [running]:
main.startMatrix.func1(0xc42001a0e0)
        /home/gitlab/maulabbot/matrix.go:58 +0x792
created by main.startMatrix
        /home/gitlab/maulabbot/matrix.go:48 +0x420

Version: 7ea206f with a minor patch:

diff --git a/matrix.go b/matrix.go
index f337a8f..ac04fb8 100644
--- a/matrix.go
+++ b/matrix.go
@@ -54,7 +54,7 @@ func startMatrix() func() {
                        case evt := <-mxbot.Timeline:
                                switch evt.Type {
                                case mautrix.EvtRoomMessage:
-                                       evt.MarkRead()
+                                       //evt.MarkRead()
                                        msg := evt.Content["body"].(string)
                                        if !strings.HasPrefix(msg, "!gitlab") {
                                                continue Loop

Database error upon first run

Trying to run v0.2.0 of this bot with a postgresql database in the maubot standalone mode, and I get the following error:

sqlalchemy.exc.ProgrammingError: (psycopg2.errors.InvalidForeignKey) there is no unique constraint matching given keys for referenced table "token"

[SQL:
CREATE TABLE "default" (
	user_id VARCHAR(255) NOT NULL,
	gitlab_server TEXT,
	PRIMARY KEY (user_id),
	FOREIGN KEY(user_id) REFERENCES token (user_id),
	FOREIGN KEY(gitlab_server) REFERENCES token (gitlab_server)
)

]

honor base_command

The default config and readme mention a base_command to use instead of !gitlab. But it seems that !gitlab is hardwired as base_command. This prevents me from having a Read-only and a RW gitlab plugin running simultanously.

So either base_command should be fixed or removed from the docs/config :-).

Retry joins

@travis:t2l.io invited me to  (!ogUNpYDgBXqPUnvnYq:t2l.io)
Unexpected error: HTTP 403: {"errcode":"M_UNKNOWN","error":"Forbidden"}
@travis:t2l.io invited me to  (!iZxBavsznvcEDWanCn:t2l.io)
Unexpected error: HTTP 403: {"errcode":"M_UNKNOWN","error":"Forbidden"}

This can happen if the server is slow and sends the invite down /sync before it's done processing.

Doesn't work with latest version of go-gitlab

Due to xanzy/go-gitlab#286

# _/home/gitlab/maulabbot
./commands.go:243:14: issue.Assignee undefined (type *"github.com/xanzy/go-gitlab".Issue has no field or method Assignee)
./commands.go:244:46: issue.Assignee undefined (type *"github.com/xanzy/go-gitlab".Issue has no field or method Assignee)

Add support for configuring webhooks with commands

Instead of requiring the user manually create the webhook, the bot should have an option to do it automatically. This will also make it possible to fix the webhook secret being public.

  • Add command to create, configure and delete room notification webhooks
  • Store per-room+webhook secrets in the db and check against those instead of the global secret

gitlab test "Issues events" not working

I can confirm that issues events are working in general, but when you trigger gitlab test for "Issues events" then is not working. Gitlab test push events and comments work as expected.

I'm pasting (masked) real examples

note-comment event

{
  "object_kind": "note",
  "event_type": "note",
  "user": {
    "name": "maskeduser",
    "username": "maskeduser",
    "avatar_url": "https://assets.gitlab-static.net/uploads/-/system/user/avatar/2/avatar.png"
  },
  "project_id": 1,
  "project": {
    "id": 1,
    "name": "test",
    "description": "",
    "web_url": "https://gitlab.com/maskeduser/test",
    "avatar_url": null,
    "git_ssh_url": "[email protected]:maskeduser/test.git",
    "git_http_url": "https://gitlab.com/maskeduser/test.git",
    "namespace": "maskeduser",
    "visibility_level": 0,
    "path_with_namespace": "maskeduser/test",
    "default_branch": "master",
    "ci_config_path": null,
    "homepage": "https://gitlab.com/maskeduser/test",
    "url": "[email protected]:maskeduser/test.git",
    "ssh_url": "[email protected]:maskeduser/test.git",
    "http_url": "https://gitlab.com/maskeduser/test.git"
  },
  "object_attributes": {
    "attachment": null,
    "author_id": 2,
    "change_position": null,
    "commit_id": null,
    "created_at": "2017-07-25 18:04:27 UTC",
    "discussion_id": "4f205ed1a1cc2e388d426f6fbebe14324f9e4d64",
    "id": 35893098,
    "line_code": null,
    "note": "changed time estimate to 1h",
    "noteable_id": 6223732,
    "noteable_type": "Issue",
    "original_position": null,
    "position": null,
    "project_id": 1,
    "resolved_at": null,
    "resolved_by_id": null,
    "resolved_by_push": null,
    "st_diff": null,
    "system": true,
    "type": null,
    "updated_at": "2017-07-25 18:04:27 UTC",
    "updated_by_id": null,
    "description": "changed time estimate to 1h",
    "url": "https://gitlab.com/maskeduser/test/issues/5#note_35893098"
  },
  "repository": {
    "name": "test",
    "url": "[email protected]:maskeduser/test.git",
    "description": "",
    "homepage": "https://gitlab.com/maskeduser/test"
  },
  "issue": {
    "author_id": 2,
    "closed_at": null,
    "confidential": false,
    "created_at": "2017-07-25 17:17:19 UTC",
    "description": "",
    "due_date": null,
    "id": 6223732,
    "iid": 5,
    "last_edited_at": "2017-07-26 06:50:06 UTC",
    "last_edited_by_id": 2,
    "milestone_id": null,
    "moved_to_id": null,
    "project_id": 1,
    "relative_position": 1073744323,
    "state": "opened",
    "time_estimate": 7200,
    "title": "new issue (title edited)",
    "updated_at": "2018-01-11 00:30:49 UTC",
    "updated_by_id": 2,
    "weight": 4,
    "url": "https://gitlab.com/maskeduser/test/issues/5",
    "total_time_spent": 14400,
    "human_total_time_spent": "4h",
    "human_time_estimate": "2h",
    "assignee_ids": [

    ],
    "assignee_id": null,
    "labels": [
      {
        "id": 3295834,
        "title": "Doing",
        "color": "#5CB85C",
        "project_id": 1,
        "created_at": "2018-01-10 21:29:10 UTC",
        "updated_at": "2018-01-10 21:29:10 UTC",
        "template": false,
        "description": null,
        "type": "ProjectLabel",
        "group_id": null
      }
    ]
  }
}

push event

{
  "object_kind": "push",
  "event_name": "push",
  "before": "11382400719febfa6877c23462d1ee2262725b63",
  "after": "d696de28cd8e99f33fe21458d7717b0c8738a950",
  "ref": "refs/heads/master",
  "checkout_sha": "d696de28cd8e99f33fe21458d7717b0c8738a950",
  "message": null,
  "user_id": 2,
  "user_name": "maskeduser",
  "user_username": "maskeduser",
  "user_email": "",
  "user_avatar": "https://assets.gitlab-static.net/uploads/-/system/user/avatar/2/avatar.png",
  "project_id": 1,
  "project": {
    "id": 1,
    "name": "test",
    "description": "",
    "web_url": "https://gitlab.com/maskeduser/test",
    "avatar_url": null,
    "git_ssh_url": "[email protected]:maskeduser/test.git",
    "git_http_url": "https://gitlab.com/maskeduser/test.git",
    "namespace": "maskeduser",
    "visibility_level": 0,
    "path_with_namespace": "maskeduser/test",
    "default_branch": "master",
    "ci_config_path": null,
    "homepage": "https://gitlab.com/maskeduser/test",
    "url": "[email protected]:maskeduser/test.git",
    "ssh_url": "[email protected]:maskeduser/test.git",
    "http_url": "https://gitlab.com/maskeduser/test.git"
  },
  "commits": [
    {
      "id": "d696de28cd8e99f33fe21458d7717b0c8738a950",
      "message": "test\n",
      "timestamp": "2018-06-06T01:58:38Z",
      "url": "https://gitlab.com/maskeduser/test/commit/d696de28cd8e99f33fe21458d7717b0c8738a950",
      "author": {
        "name": "maskeduser",
        "email": "[email protected]"
      },
      "added": [

      ],
      "modified": [
        "README.md"
      ],
      "removed": [

      ]
    },
    {
      "id": "1adeafcc60f3599c89f0974b14aeec4ea73f5422",
      "message": "more\n",
      "timestamp": "2018-06-06T01:53:43Z",
      "url": "https://gitlab.com/maskeduser/test/commit/1adeafcc60f3599c89f0974b14aeec4ea73f5422",
      "author": {
        "name": "maskeduser",
        "email": "[email protected]"
      },
      "added": [

      ],
      "modified": [
        "README.md"
      ],
      "removed": [

      ]
    },
    {
      "id": "11382400719febfa6877c23462d1ee2262725b63",
      "message": "my change\n",
      "timestamp": "2018-06-06T01:47:57Z",
      "url": "https://gitlab.com/maskeduser/test/commit/11382400719febfa6877c23462d1ee2262725b63",
      "author": {
        "name": "maskeduser",
        "email": "localhost"
      },
      "added": [

      ],
      "modified": [
        "README.md"
      ],
      "removed": [

      ]
    }
  ],
  "total_commits_count": 3,
  "push_options": {
  },
  "repository": {
    "name": "test",
    "url": "[email protected]:maskeduser/test.git",
    "description": "",
    "homepage": "https://gitlab.com/maskeduser/test",
    "git_http_url": "https://gitlab.com/maskeduser/test.git",
    "git_ssh_url": "[email protected]:maskeduser/test.git",
    "visibility_level": 0
  }
}

issue event

{
  "object_kind": "issue",
  "event_type": "issue",
  "user": {
    "name": "maskeduser",
    "username": "maskeduser",
    "avatar_url": "https://assets.gitlab-static.net/uploads/-/system/user/avatar/2/avatar.png"
  },
  "project": {
    "id": 1,
    "name": "test",
    "description": "",
    "web_url": "https://gitlab.com/maskeduser/test",
    "avatar_url": null,
    "git_ssh_url": "[email protected]:maskeduser/test.git",
    "git_http_url": "https://gitlab.com/maskeduser/test.git",
    "namespace": "maskeduser",
    "visibility_level": 0,
    "path_with_namespace": "maskeduser/test",
    "default_branch": "master",
    "ci_config_path": null,
    "homepage": "https://gitlab.com/maskeduser/test",
    "url": "[email protected]:maskeduser/test.git",
    "ssh_url": "[email protected]:maskeduser/test.git",
    "http_url": "https://gitlab.com/maskeduser/test.git"
  },
  "object_attributes": {
    "author_id": 2,
    "closed_at": null,
    "confidential": false,
    "created_at": "2017-07-25 17:10:57 UTC",
    "description": "asdfasdf",
    "due_date": null,
    "id": 6223691,
    "iid": 1,
    "last_edited_at": null,
    "last_edited_by_id": null,
    "milestone_id": null,
    "moved_to_id": null,
    "project_id": 1,
    "relative_position": 1073742323,
    "state": "opened",
    "time_estimate": 0,
    "title": "test",
    "updated_at": "2018-01-10 21:29:13 UTC",
    "updated_by_id": 2,
    "weight": null,
    "url": "https://gitlab.com/maskeduser/test/issues/1",
    "total_time_spent": 0,
    "human_total_time_spent": null,
    "human_time_estimate": null,
    "assignee_ids": [

    ],
    "assignee_id": null,
    "labels": [

    ]
  },
  "labels": [

  ],
  "changes": {
    "total_time_spent": {
      "previous": null,
      "current": 0
    }
  },
  "repository": {
    "name": "test",
    "url": "[email protected]:maskeduser/test.git",
    "description": "",
    "homepage": "https://gitlab.com/maskeduser/test"
  }
}

Allow different access_token logins based on project

Hi,

first of all thanks for the maubot, especially the gitlab-plugin.

Now i am setting up multiple rooms where the bot shall keep the members updated about a different project. Therefore i tried to login to the gitlab-server multiple times (from each room with the projects access_token only to find out that i can login to a server only once.

sqlite3.IntegrityError: UNIQUE constraint failed: token.user_id, token.gitlab_server

To allow one bot to manage multiple projects on one server it is necessary to give the bot an access_token created for a user who is able to access all these projects. This is suboptimal in my opinion.
Instead i wish for the ability to link a room to a specific access_token (if specified). Also in order to keep members in other rooms from messing up projects they don't belong to.

I am not familar with python, although I can offer to test.

cheers,
smoe

GitLab plugin fails to start: TypeError: 'ABCMeta' object is not subscriptable

Hi there,

probably since upgrading to maubot 0.2.0 the GitLab plugin (v0.1.1) fails to start with the following error:

[2021-11-22 09:10:27,392] [[email protected]] Initializing maubot 0.2.0
[...]
[2021-11-22 09:10:27,995] [[email protected]] Failed to load xyz.maubot.gitlab v0.1.1
Traceback (most recent call last):
  File "/opt/maubot/maubot/loader/zip.py", line 203, in _load
    importer.load_module(module)
  File "/opt/maubot/maubot/lib/zipimport.py", line 282, in load_module
    exec(code, mod.__dict__)
  File "/data/plugins/xyz.maubot.gitlab-v0.1.1.mbp/gitlab_matrix/__init__.py", line 1, in <module>
    from .bot import GitlabBot
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 627, in _load_backward_compatible
  File "<frozen zipimport>", line 259, in load_module
  File "/data/plugins/xyz.maubot.gitlab-v0.1.1.mbp/gitlab_matrix/bot.py", line 24, in <module>
    from .webhook import GitlabWebhook
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 627, in _load_backward_compatible
  File "<frozen zipimport>", line 259, in load_module
  File "/data/plugins/xyz.maubot.gitlab-v0.1.1.mbp/gitlab_matrix/webhook.py", line 32, in <module>
    from .types import GitlabJobEvent, EventParse, Action, OTHER_ENUMS
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 627, in _load_backward_compatible
  File "<frozen zipimport>", line 259, in load_module
  File "/data/plugins/xyz.maubot.gitlab-v0.1.1.mbp/gitlab_matrix/types.py", line 76, in <module>
    class GitlabLabel(SerializableAttrs['GitlabLabel']):
TypeError: 'ABCMeta' object is not subscriptable

Any ideas?

Environment:

  • Docker
  • maubot 0.2.0
  • GitLab CE 14.4.2

Thanks,
Thilo

Bot is sending illegal html attributes

In the Matrix spec it is very hard specified which HTML tags and attributes are allowed in formatted messages. When using the native setInnerHtml method with a node validator in a browser, it complains a lot in the logs which afaik can't be muted:

Removing disallowed attribute <SPAN title="Issues relevant to the frontend team"> [main.dart.js:12596:47](https://famedly.gitlab.io/company/frontend/famedly-web/main.dart.js)
Removing disallowed attribute <SPAN title="This issue is intended to be the place for an open discussion about a specific topic."> [main.dart.js:12596:47](https://famedly.gitlab.io/company/frontend/famedly-web/main.dart.js)
Removing disallowed attribute <A data-mautrix-exclude-plaintext=""> [main.dart.js:12596:47](https://famedly.gitlab.io/company/frontend/famedly-web/main.dart.js)
Removing disallowed attribute <STRONG data-mautrix-exclude-plaintext=""> [main.dart.js:12596:47](https://famedly.gitlab.io/company/frontend/famedly-web/main.dart.js)
Removing disallowed attribute <A data-mautrix-exclude-plaintext=""> 2 [main.dart.js:12596:47](https://famedly.gitlab.io/company/frontend/famedly-web/main.dart.js)
Removing disallowed attribute <STRONG data-mautrix-exclude-plaintext=""> [main.dart.js:12596:47](https://famedly.gitlab.io/company/frontend/famedly-web/main.dart.js)
Removing disallowed attribute <A data-mautrix-exclude-plaintext=""> 2 [main.dart.js:12596:47](https://famedly.gitlab.io/company/frontend/famedly-web/main.dart.js)
Removing disallowed attribute <STRONG data-mautrix-exclude-plaintext=""> [main.dart.js:12596:47](https://famedly.gitlab.io/company/frontend/famedly-web/main.dart.js)
Removing disallowed attribute <A data-mautrix-exclude-plaintext=""> 2 [main.dart.js:12596:47](https://famedly.gitlab.io/company/frontend/famedly-web/main.dart.js)
Removing disallowed attribute <STRONG data-mautrix-exclude-plaintext=""> [main.dart.js:12596:47](https://famedly.gitlab.io/company/frontend/famedly-web/main.dart.js)
Removing disallowed attribute <A data-mautrix-exclude-plaintext=""> 2 [main.dart.js:12596:47](https://famedly.gitlab.io/company/frontend/famedly-web/main.dart.js)
Removing disallowed attribute <STRONG data-mautrix-exclude-plaintext=""> [main.dart.js:12596:47](https://famedly.gitlab.io/company/frontend/famedly-web/main.dart.js)
Removing disallowed attribute <A data-mautrix-exclude-plaintext=""> 4 [main.dart.js:12596:47](https://famedly.gitlab.io/company/frontend/famedly-web/main.dart.js)
Removing disallowed attribute <STRONG data-mautrix-exclude-plaintext=""> [main.dart.js:12596:47](https://famedly.gitlab.io/company/frontend/famedly-web/main.dart.js)
Removing disallowed attribute <A data-mautrix-exclude-plaintext=""> 2 [main.dart.js:12596:47](https://famedly.gitlab.io/company/frontend/famedly-web/main.dart.js)
Removing disallowed attribute <STRONG data-mautrix-exclude-plaintext=""> [main.dart.js:12596:47](https://famedly.gitlab.io/company/frontend/famedly-web/main.dart.js)
Removing disallowed attribute <A data-mautrix-exclude-plaintext=""> [main.dart.js:12596:47](https://famedly.gitlab.io/company/frontend/famedly-web/main.dart.js)
Removing disallowed attribute <SPAN title="Issues that are actionable / can be picked up for work"> [main.dart.js:12596:47](https://famedly.gitlab.io/company/frontend/famedly-web/main.dart.js)
Removing disallowed attribute <SPAN title="In progress"> [main.dart.js:12596:47](https://famedly.gitlab.io/company/frontend/famedly-web/main.dart.js)
Removing disallowed attribute <A data-mautrix-exclude-plaintext=""> [main.dart.js:12596:47](https://famedly.gitlab.io/company/frontend/famedly-web/main.dart.js)
Removing disallowed attribute <STRONG data-mautrix-exclude-plaintext=""> [main.dart.js:12596:47](https://famedly.gitlab.io/company/frontend/famedly-web/main.dart.js)
Removing disallowed attribute <A data-mautrix-exclude-plaintext=""> 2 [main.dart.js:12596:47](https://famedly.gitlab.io/company/frontend/famedly-web/main.dart.js)
Removing disallowed attribute <STRONG data-mautrix-exclude-plaintext=""> [main.dart.js:12596:47](https://famedly.gitlab.io/company/frontend/famedly-web/main.dart.js)
Removing disallowed attribute <A data-mautrix-exclude-plaintext=""> [main.dart.js:12596:47](https://famedly.gitlab.io/company/frontend/famedly-web/main.dart.js)
Removing disallowed attribute <SPAN title="Issues relevant to the frontend team"> [main.dart.js:12596:47](https://famedly.gitlab.io/company/frontend/famedly-web/main.dart.js)
Removing disallowed attribute <SPAN title="This issue is intended to be the place for an open discussion about a specific topic."> [main.dart.js:12596:47](https://famedly.gitlab.io/company/frontend/famedly-web/main.dart.js)
Removing disallowed attribute <A data-mautrix-exclude-plaintext=""> [main.dart.js:12596:47](https://famedly.gitlab.io/company/frontend/famedly-web/main.dart.js)
Removing disallowed attribute <STRONG data-mautrix-exclude-plaintext=""> [main.dart.js:12596:47](https://famedly.gitlab.io/company/frontend/famedly-web/main.dart.js)
Removing disallowed attribute <A data-mautrix-exclude-plaintext="">

Is there an alternative for using "title" or "data-*" attributes?

Documentation issues in README

  • "Maubot Manager > Instances > my_gitlab_bot" does not have a "path" displayed on the page. I figured out independently that the path is "/webhooks"
  • if the user does not hit "Save" on the created instance page, the gitlab hook secret will change every time the docker container is restarted. I verified that the instance exists but the config is blank in the DB in this case.

Extraneous newlines before and after commits

Commit notifications look like

{
  "origin_server_ts": 1523959677668,
  "sender": "@gitlab:t2bot.io",
  "event_id": "$152395967761790mbtyQ:t2bot.io",
  "unsigned": {
    "age": 13490826
  },
  "content": {
    "body": "\nInstall command with ninja, and fix new-release script (c47d98a4)\nRemove configure script (25a61ea9)\n\n",
    "msgtype": "m.notice",
    "formatted_body": "<ul>\n<li>Install command with ninja, and fix new-release script (c47d98a4)</li>\n<li>Remove configure script (25a61ea9)</li>\n</ul>\n",
    "format": "org.matrix.custom.html"
  },
  "type": "m.room.message",
  "room_id": "!hwiGbsdSTZIwSRfybq:matrix.org"
}

with unneeded \n before and after. Riot trims them but one shouldn’t rely on that behaviour. Please remove them.

not enough arguments in call to git.Commits.GetCommitDiff

Hi, Trying to build maulabbot and getting this:

$ go get github.com/tulir/maulabbot
# github.com/tulir/maulabbot
../../go/src/github.com/tulir/maulabbot/commands.go:160:44: not enough arguments in call to git.Commits.GetCommitDiff
	have (string, string)
	want (interface {}, string, *"github.com/xanzy/go-gitlab".GetCommitDiffOptions, ..."github.com/xanzy/go-gitlab".OptionFunc)
../../go/src/github.com/tulir/maulabbot/commands.go:311:14: unknown field 'ListOptions' in struct literal of type "github.com/xanzy/go-gitlab".ListIssueNotesOptions

I am a complete go illiterate so I may be missing something pretty obvious here.

KeyError: 'Deployment Hook'

Following error occurs sometimes (probably when receiving a gitlab hook):

Failed to handle Gitlab event
Traceback (most recent call last):
  File "/home/service/maubot/plugins/xyz.maubot.gitlab-v0.1.0.mbp/gitlab_matrix/bot.py", line 121, in process_hook
    evt = EventParse[req.headers["X-Gitlab-Event"]].deserialize(body)
KeyError: 'Deployment Hook'

Link back to Matrix message for issues created with `!gitlab issue create ...`

When an issue is created (with !gitlab issue create ...) the bridge writes the issue content exactly as given with no additional information.

I suggest including a horizontal line (hr) and some text like "This issue was submitted through Matrix. View the message."

where 'View the message' is a riot.im link in the format of: https://riot.im/app/#/room/!roomID:matrix.org/$messageID:matrix.org

(it might be more "official" to use matrix.to links, but I don't like them. not ultimately my choice, though.)

This has a couple of advantages:

  1. It's useful to know if an issue has created in a nonconventional way. The same would be true if you created an issue via email (for example). Bridges like this are hard to maintain because both sides of the bridge are independent. Some bugs are expected, but at least we can tell when the bridge is involved.
  2. Linking back to the Riot message gives GitLab users the ability to jump right back into that chat conversation at any time. So when we decide we need a feature and have a whole conversation about it in the chat, we can access that chat log 6 months later when the feature is actually being implemented.

Thanks for your work on this!! It's been a great help to the communities I'm a part of. 😄

Failed to deserialize lock_on_merge into key labels of GitlabIssueAttributes

It appears that GitLab Labels have a new attribute lock_on_merge: bool, added in https://gitlab.com/gitlab-org/gitlab/-/merge_requests/128667, which is part of a not yet merged feature: https://gitlab.com/gitlab-org/gitlab/-/issues/408676.

GitLab version: 16.3.4-ce.0 from https://packages.gitlab.com/gitlab/gitlab-ce/debian/ buster main

The exception occurs in webhooks for GitLab Issues that contain labels:

[2023-09-19 13:31:11,227] [[email protected]] Failed to process webhook
Traceback (most recent call last):
  File "/opt/maubot/env/lib/python3.11/site-packages/mautrix/types/util/serializable_attrs.py", line 198, in _dict_to_attrs
    new_items[name] = _try_deserialize(field_meta, value)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/maubot/env/lib/python3.11/site-packages/mautrix/types/util/serializable_attrs.py", line 229, in _try_deserialize
    return _deserialize(field.type, value, field.default)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/maubot/env/lib/python3.11/site-packages/mautrix/types/util/serializable_attrs.py", line 277, in _deserialize
    return _deserialize(args[0], value, default)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/maubot/env/lib/python3.11/site-packages/mautrix/types/util/serializable_attrs.py", line 280, in _deserialize
    return [_deserialize(item_cls, item) for item in value]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/maubot/env/lib/python3.11/site-packages/mautrix/types/util/serializable_attrs.py", line 280, in <listcomp>
    return [_deserialize(item_cls, item) for item in value]
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/maubot/env/lib/python3.11/site-packages/mautrix/types/util/serializable_attrs.py", line 267, in _deserialize
    return _dict_to_attrs(cls, value, default, default_if_empty=True)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/maubot/env/lib/python3.11/site-packages/mautrix/types/util/serializable_attrs.py", line 223, in _dict_to_attrs
    obj.unrecognized_ = unrecognized
    ^^^^^^^^^^^^^^^^^
  File "/opt/maubot/env/lib/python3.11/site-packages/attr/_make.py", line 605, in _frozen_setattrs
    raise FrozenInstanceError()
attr.exceptions.FrozenInstanceError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/var/opt/maubot/test/plugins/xyz.maubot.gitlab-v0.2.1.1-ts1694083715170.mbp/gitlab_matrix/webhook.py", line 120, in try_process_hook
    await self.process_hook(body, evt_type, room_id)
  File "/var/opt/maubot/test/plugins/xyz.maubot.gitlab-v0.2.1.1-ts1694083715170.mbp/gitlab_matrix/webhook.py", line 134, in process_hook
    evt = EventParse[evt_type].deserialize(body]
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/maubot/env/lib/python3.11/site-packages/mautrix/types/util/serializable_attrs.py", line 375, in deserialize
    return _dict_to_attrs(cls, data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/maubot/env/lib/python3.11/site-packages/mautrix/types/util/serializable_attrs.py", line 198, in _dict_to_attrs
    new_items[name] = _try_deserialize(field_meta, value)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/maubot/env/lib/python3.11/site-packages/mautrix/types/util/serializable_attrs.py", line 229, in _try_deserialize
    return _deserialize(field.type, value, field.default)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/maubot/env/lib/python3.11/site-packages/mautrix/types/util/serializable_attrs.py", line 267, in _deserialize
    return _dict_to_attrs(cls, value, default, default_if_empty=True)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/maubot/env/lib/python3.11/site-packages/mautrix/types/util/serializable_attrs.py", line 206, in _dict_to_attrs
    raise SerializerError(
mautrix.types.util.serializable.SerializerError: Failed to deserialize [{'id': 497, 'title': 'testlabel', 'color': '#6699cc', 'project_id': 3431, 'created_at': '2023-09-19 11:30:49 UTC', 'updated_at': '2023-09-19 11:30:49 UTC', 'template': False, 'description': None, 'type': 'ProjectLabel', 'group_id': None, 'lock_on_merge': False}] into key labels of GitlabIssueAttributes

This appears to fix it:

diff --git a/gitlab_matrix/types.py b/gitlab_matrix/types.py
index 8fb9fa7..666c5da 100644
--- a/gitlab_matrix/types.py
+++ b/gitlab_matrix/types.py
@@ -89,6 +89,7 @@ class GitlabLabel(SerializableAttrs):
     description: str
     type: LabelType
     group_id: Optional[int]
+    lock_on_merge: Optional[bool]
     remove_on_close: bool = False

     @property

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.