Skip to content

Fix bot POST request, update deps

Hunter Stewart requested to merge hustewart-fix-bot-parse-error into master

Why

Milestone bot is failing because we're trying to POST the entire comment in the URI itself instead of using a body.

The failure looks like

Posting comment...
gitlab-4.19.0/lib/gitlab/request.rb:71:in `validate': Server responded with code 414, message: <html>\r (Gitlab::Error::ResponseError)
<head><title>414 Request-URI Too Large</title></head>\r
<body>\r
<center><h1>414 Request-URI Too Large</h1></center>\r
<hr><center>nginx</center>\r
</body>\r
</html>\r

and the reason is the POST:

  def post_comment(current_planning_issue_iid:, body:)
    client.post(
      "/projects/#{GENERAL_PROJECT_ID}/issues/#{current_planning_issue_iid}/notes?body=#{body}"
    )
  end

Putting the body in the URI like this causes a 414 on larger comments.

What

  • use a body instead of URI to post comment

Since this is a small project I added a couple of other things as well:

  • When I tried a dry run locally it failed on the Date call, so I added a require to make that work.
  • We are behind on a gitlab gem version so I updated the bundle.

Validate locally

Here's my example comment after fix: #73 (comment 1900587404)

For this small project it's probably not worth someone else setting up local validation as well. I would just merge it and run the pipeline.

But if you'd like to, you'll need to clone the project, set up the correct tokens/env variables the project uses for auth, and then run ruby ./tools/update_milestone.rb in the project. It will actually post to the issue so you may want to delete any extra posts you create to avoid clutter/noise. Using the dry run flag won't help you with this because that skips the broken part which is the POST.

Edited by Hunter Stewart

Merge request reports