Support for Quick Actions responses when making a Merge Request Note
In the NotesAPI, when calling createMergeRequestNote (https://docs.gitlab.com/api/notes/#create-new-merge-request-note), if you use entirely Quick Actions, no note is created. This also means the response body doesn't match the Note class. Instead, it has the following fields:
- commands_changes: A map showing all the changed fields in the MR
- summary: A string that is a summary of all the changes made, and errors if there were any
For example:
curl -vvv --request POST \
--header "PRIVATE-TOKEN: glpat-<REDACTED>" \
--header "Content-Type: application/json" \
--data '{"body": "/draft\n/assign_reviewer @GitLabDuo\n/label ~\"my-test\""}' \
"https://gitlab.com/api/v4/projects/9372/merge_requests/22/notes"
{
"commands_changes": {
"add_label_ids": [
432
],
"wip_event": "draft"
},
"summary": [
"No change to this merge request's draft status. Your account doesn't have GitLab Duo access. Please contact your system administrator for access. Added ~\"my-test\" label."
]
}
Very interesting… Any idea what should be the structure of the commands_changes JSON attribute?
This doesn't seems to be specified anywhere on the page you linked.
Same for summary this does not appear at all in the docs.
I am wondering what should be the java types in the returned object in this object:
https://github.com/gitlab4j/gitlab4j-api/blob/952ce3152d019136749d3ba1bab0e2de8fb63565/gitlab4j-api/src/main/java/org/gitlab4j/api/NotesApi.java#L166
@jmini Here is the endpoint that returns the values
https://gitlab.com/gitlab-org/gitlab/-/blob/4d5af20bf55d3eee7690523d1431ed92756722cf/lib/api/entities/note.rb#L48-51
These are a list of the possible values under commands_changes:
https://gitlab.com/gitlab-org/gitlab/-/blob/4d5af20bf55d3eee7690523d1431ed92756722cf/app/models/note.rb#L634-667
There is currently no documentation. I am not sure how to read beyond this to find the possible values for each one, aside from asking AI to generate a list from the code base (which I did below). But each value would have to be manually verified. I guess you could return "Object" types for now until official documentation is released. The commands_changes parameter could be a Map<String, Object>. summary is a String.
Really, what's important to my implementation is just the summary, not the commands_changes, since this is something that is configured by users and they want a human readable summary, which GitLab provides in that string. If someone was programmatically trying to do something specific, and needed the results of commands_changes, they would just use the API endpoint designed for that specific action. The purpose of Quick Actions is to provide a general purpose implementation. But I can't speak for everyone.
AI Generated list (not verified):
| Field | Type | Example Values | Related Quick Action |
|---|---|---|---|
due_date |
String (ISO date) | "2024-12-31" |
/due |
label_ids |
Array of integers | [1, 2, 3] |
/label |
remove_label_ids |
Array of integers | [4, 5] |
/unlabel |
add_label_ids |
Array of integers | [6, 7] |
/label |
canonical_issue_id |
Integer | 123 |
/duplicate |
clone_with_notes |
Boolean | true |
/clone |
confidential |
Boolean | true/false |
/confidential |
create_merge_request |
Hash | {branch_name: "feature", title: "Fix"} |
/create_merge_request |
add_contacts |
Array of integers | [1, 2] |
/add_contacts |
remove_contacts |
Array of integers | [3, 4] |
/remove_contacts |
assignee_ids |
Array of integers | [10, 20] |
/assign |
milestone_id |
Integer | 5 |
/milestone |
time_estimate |
Integer (seconds) | 3600 |
/estimate |
spend_time |
Integer (seconds) | 1800 |
/spend |
discussion_locked |
Boolean | true/false |
/lock |
merge |
Boolean | true |
/merge |
rebase |
Boolean | true |
/rebase |
wip_event |
String | "wip"/"ready" |
/draft, /ready |
target_branch |
String | "main" |
/target_branch |
reviewer_ids |
Array of integers | [30, 40] |
/request_review |
health_status |
String | "on_track"/"needs_attention"/"at_risk" |
/health_status |
promote_to_epic |
Boolean | true |
/promote |
weight |
Integer | 3 |
/weight |
emoji_award |
Hash | {name: "thumbsup", action: "add"} |
/award |
todo_event |
String | "add"/"done" |
/todo |
subscription_event |
String | "subscribe"/"unsubscribe" |
/subscribe |
state_event |
String | "close"/"reopen" |
/close, /reopen |
title |
String | "New title" |
/title |
tag_message |
String | "Release message" |
/tag |
tag_name |
String | "v1.0.0" |
/tag |
Very nice insights into the ruby code.