ChatGPT Automatic Code Review in Gitlab MR

Describe the problem/error/question

I’ve use this template and edit something for working on on n8n 1.76.2

  • At ‘Get Changes1’ step: Edit
https://gitlab.com/api/v4/projects/{{ $json["body"]["project_id"] }}/merge_requests/{{ $json["body"]["merge_request"]["iid"] }}/changes

to 

https://gitlab.com/api/v4/projects/{{ $json.body.project.id }}/merge_requests/{{ $json.body.object_attributes.iid }}/changes
  • At ‘Post Discussions1’ step: Edit
https://gitlab.com/api/v4/projects/{{ $('Webhook').item.json["body"]["project_id"] }}/merge_requests/{{ $('Webhook').item.json["body"]["merge_request"]["iid"] }}/discussions

to

https://gitlab.com/api/v4/projects/{{ $('Webhook').item.json.body.project.id }}/merge_requests/{{ $('Webhook').item.json.body.object_attributes.iid}}/discussions

Run it and I get an error at the last step ‘Post Discussion’.

Error:

Bad request - please check your parameters [item 0]
400 Bad request - Note {:line_code=>["can't be blank", "must be a valid line code"]}

However, if I copy the body of “formData” in the error detail and post by Postman, it works.
The body of “formData” is:

{
"body": "**Decision: Reject** \n**Change Score: 20**\n\n### Issues Identified:\n1. **Redundant Entries**: The addition of \"commit\" and \"commit2\" creates duplication of the word \"commit\" which does not provide additional value or clarity in the context.\n2. **Format Misalignment**: The proposed changes do not conform to standard commit/transaction reporting formats and could lead to confusion.\n3. **Poor Documentation**: There's no indication of why these changes are necessary or what purpose they serve, leading to ambiguity for maintainers. \n\n### Recommendations:\nIf the intention is to track multiple commit messages, consider using a structured format that clearly defines each entry. For example:\n\n```text\ncommit\ncommit2: Description of what commit2 accomplishes\n```\n\nImplement necessary context and clarity before resubmitting.",
"position[position_type]": "text",
"position[old_path]": "test.txt",
"position[new_path]": "test.txt",
"position[start_sha]": "febcb67229d0b14643eb3c6b1d04dd2d8c3a7caf",
"position[head_sha]": "7ab0f1127e9b162422686febaffc2386c5584b1a",
"position[base_sha]": "febcb67229d0b14643eb3c6b1d04dd2d8c3a7caf",
"position[new_line]": -1,
"position[old_line]": -1
}

What is the error message (if any)?

Bad request - please check your parameters [item 0]
400 Bad request - Note {:line_code=>["can't be blank", "must be a valid line code"]}

Could anybody help me find out how to fix this?

Please share your workflow

(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)

Share the output returned by the last node

Error as above

Information on your n8n setup

  • n8n version: 1.76.2
  • Database (default: SQLite): Postgres
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system: Ubuntu 24

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.