I looked at the webhooks sent when commenting on issues, merge requests, commits, and snippets. I noticed that the webhook received when commenting on a snippet did not include a field that would precisely tell the URL of that snippet.
I was expecting the URL to be at payload["snippet"]["url"]
as is the case for others. For eg. the merge request URL can be found at payload["merge_request"]["url"]
. I wonder is there any specific reason why is that the case.
Sample webhook sent by GitLab when commenting on a snippet
{
"object_kind": "note",
"event_type": "note",
"user": {
"id": 14613894,
"name": "Satyam Bansal",
"username": "sbansal1999",
"avatar_url": "https://secure.gravatar.com/avatar/f4dd7cfc79fac91db4d9ecbb443a0519?s=80&d=identicon",
"email": "[REDACTED]"
},
"project_id": 46186758,
"project": {
"id": 46186758,
"name": "testing-zulip-gitlab-integration",
"description": null,
"web_url": "https://gitlab.com/sbansal1999/testing-zulip-gitlab-integration",
"avatar_url": null,
"git_ssh_url": "git@gitlab.com:sbansal1999/testing-zulip-gitlab-integration.git",
"git_http_url": "https://gitlab.com/sbansal1999/testing-zulip-gitlab-integration.git",
"namespace": "Satyam Bansal",
"visibility_level": 0,
"path_with_namespace": "sbansal1999/testing-zulip-gitlab-integration",
"default_branch": "main",
"ci_config_path": "",
"homepage": "https://gitlab.com/sbansal1999/testing-zulip-gitlab-integration",
"url": "git@gitlab.com:sbansal1999/testing-zulip-gitlab-integration.git",
"ssh_url": "git@gitlab.com:sbansal1999/testing-zulip-gitlab-integration.git",
"http_url": "https://gitlab.com/sbansal1999/testing-zulip-gitlab-integration.git"
},
"object_attributes": {
"attachment": null,
"author_id": 14613894,
"change_position": null,
"commit_id": null,
"created_at": "2023-05-25 19:15:26 UTC",
"discussion_id": "9577cb83fc7048c31ec83a81ec6095336f22f171",
"id": 1406351622,
"line_code": null,
"note": "Why there are so many new new features?",
"noteable_id": 2547713,
"noteable_type": "Snippet",
"original_position": null,
"position": null,
"project_id": 46186758,
"resolved_at": null,
"resolved_by_id": null,
"resolved_by_push": null,
"st_diff": null,
"system": false,
"type": null,
"updated_at": "2023-05-25 19:15:26 UTC",
"updated_by_id": null,
"description": "Why there are so many new new features?",
"url": "https://gitlab.com/sbansal1999/testing-zulip-gitlab-integration/-/snippets/2547713#note_1406351622"
},
"repository": {
"name": "testing-zulip-gitlab-integration",
"url": "git@gitlab.com:sbansal1999/testing-zulip-gitlab-integration.git",
"description": null,
"homepage": "https://gitlab.com/sbansal1999/testing-zulip-gitlab-integration"
},
"snippet": {
"id": 2547713,
"title": "a very new new feature",
"content": "a very new new feature\na very new new feature\na very new new feature\na very new new feature\na very new new feature",
"author_id": 14613894,
"project_id": 46186758,
"created_at": "2023-05-25 19:13:05 UTC",
"updated_at": "2023-05-25 19:15:26 UTC",
"file_name": "",
"type": "ProjectSnippet",
"visibility_level": 0,
"description": "",
"encrypted_secret_token": null,
"encrypted_secret_token_iv": null,
"secret": false,
"repository_read_only": false,
"secret_token": null
}
}