Skip to content

import/export to gitlab is broken at HEAD due to upstream changing the message format #1367

Closed

Description

@sudoforge

https://github.com/git-bug/git-bug/actions/runs/14547588831/job/40815002321#step:5:142

this tree was branched off of HEAD at 52f42da

this is likely caused by a change to gitlab's api

Activity

  1. added
    kind/bugRelates to an issue
    priority/important-soonMust be staffed and worked on either currently, or very soon, ideally in time for the next release
    and removed on Apr 19, 2025
  2. added this to the 0.8.1 (next) milestone on Apr 19, 2025
  3. added theissue type on Apr 19, 2025
  4. removed theissue type on Apr 19, 2025
  5. added 4 commits that reference this issue on Apr 19, 2025
    bb7148f
    6740cfc
    2bb2291
    5d5d30c
  6. sudoforge commented on Apr 20, 2025

    @sudoforge
    ContributorAuthor

    i started on this, but will be AFK for a few days so i won't be able to complete it. if you're interested in the status: there's a detailed comment in the commit; take a look at the PR: #1370

  7. self-assigned this
    on Apr 20, 2025
  8. sudoforge commented on Apr 20, 2025

    @sudoforge
    ContributorAuthor

    opened an upstream issue: https://gitlab.com/gitlab-org/gitlab/-/issues/536827

    i have no idea if that's the right place. they have a ton of projects and no clear direction on where to file "API issues".

  9. changed the title [-]TestGitlabPushPull is broken[/-] [+]import/export to gitlab is broken at HEAD due to upstream changing the message format[/+] on Apr 20, 2025
  10. sudoforge commented on Apr 23, 2025

    @sudoforge
    ContributorAuthor

    i'll summarize the root cause here for people who'd rather not read the thread on gitlab (there's a bit of back and forth about how to potentially improve this scenario, if you're interested).


    when importing from gitlab, in order to get the historical events related to a gitlab issue, we hit the "issue notes api", and get a list of objects that look like this:

    {
      "id": 123412341234,
      "type": null,
      "body": "changed title from **bug title edited** to **bug title edited{+ again+}**",
      "author": {
        ...
      },
      "created_at": "2024-03-19T20:56:59.456Z",
      "updated_at": "2024-03-19T20:56:59.463Z",
      "system": true,
      "noteable_id": 12341234,
      "noteable_type": "Issue",
      "project_id": 12341234,
      "resolvable": false,
      "confidential": false,
      "internal": false,
      "imported": false,
      "imported_from": "none",
      "noteable_iid": 1,
      "commands_changes": {}
    }
    

    the critical field here is the body field. this value represents that the title was changed from bug title edited to bug title edited again.

    gitlab uses this sort of message to render the "comments" that are added to issues when different event types occur: a title being changed, a mention from somewhere else, commits being added, etc. this comprises the "notes" that get added to an issue's feed (you can see a similar thing on github issues, above, for example). for this use case, gitlab doesn't care about the body field's value -- they just dump it into SomeRenderer that spits out something for their UI.

    conversely, git-bug cares about the type of event. we track these events as strongly typed "operations", and therefore, we need to parse this event.

    historically, this field's value looked like what you see above. with the advent of the 17.11 release, however, gitlab changed the format of the value.

    this means that the following two values represent the exact same title change, from bug title edited to bug title edited again:

    original

    changed title from **bug title edited** to **bug title edited{+ again+}**
    

    post-17.11

    <p>changed title from <code class=\"idiff\">bug title edited</code> to <code class=\"idiff\">bug title edited<span class=\"idiff left right addition\"> again</span></code></p>
    

    the kicker here is that this only impacts newly created issue notes. older issue notes still use the original markdown-esque format.


    as can be seen from this issue, the approach we take to determine the type of "note" (rather, "event" as we think about it) is pretty fragile, and relies on a loosely typed value that isn't part of gitlab's API contract. unfortunately, there doesn't appear to be another way for us to get this information -- although it's possible gitlab could add support for our use case in the future.

    in the short term, we'll have to conditionally use the new parser i wrote in #1370, falling back to the older parser. it doesn't seem like there's an exact timestamp we can use for determining if the body field will be in the new or old format, so the best course of action will just be a brute force approach using a regex.

  11. added a commit that references this issue on Apr 25, 2025
    9205eaf
  12. added a commit that references this issue on Apr 25, 2025
    197eb59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/bridge/gitlabRelates to the GitLab bridgekind/bugRelates to an issuepriority/important-soonMust be staffed and worked on either currently, or very soon, ideally in time for the next release

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions