Skip to content

Fixes and improvements#2

Merged
nickmarden merged 3 commits intonickmarden:so-many-slashesfrom
massawho:bugfix/group-id
Mar 31, 2026
Merged

Fixes and improvements#2
nickmarden merged 3 commits intonickmarden:so-many-slashesfrom
massawho:bugfix/group-id

Conversation

@massawho
Copy link
Copy Markdown

  1. Improve error reporting
  2. Fix KeyError: 'group_id'
  3. Truncate Merge Request titles

Enhance error reporting by capturing and logging subprocess output on failure.
This ensures that the specific reasons for Git command failures (such as
GitLab pre-receive hook rejections) are visible in the logs.

Before this change, the script would only report that a command failed
with "exit status 1," leaving the actual cause a mystery. Now, it provides
the full context needed for debugging.
Rename key `group` to `group_id` of self.gitlab hashmap to avoid
exception below

Traceback (most recent call last):
  File ".../venv/github2gitlab/bin/github2gitlab", line 25, in <module>
    sys.exit(GitHub2GitLab.factory(sys.argv[1:]).run())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../venv/github2gitlab/github2gitlab/main.py", line 163, in run
    if self.add_project():
       ^^^^^^^^^^^^^^^^^^
  File ".../venv/github2gitlab/github2gitlab/main.py", line 321, in add_project
    if g['group_id']:
       ~^^^^^^^^^^^^
KeyError: 'group_id'
Truncate Merge Request titles to 255 characters to comply with GitLab API
limits. This prevents crashes when syncing GitHub Pull Requests with very
long titles and ensures stable comparisons during updates.

1. Creation Logic (sync): Truncates the GitHub pull request title to 255
characters when creating a new Merge Request on GitLab. This prevents the
initial ValueError you encountered.

2. Update Logic (field_update): Ensures that if a title is updated later
(e.g., someone renames the PR on GitHub), the new title sent to GitLab is
also truncated to 255 characters.

3. Comparison Logic (field_equal): Truncates both the GitHub and GitLab titles
before comparing them. This is crucial because it prevents the script from
thinking the titles are different just because one is 300 characters
(on GitHub) and the other is 255 characters (on GitLab), which would
otherwise cause an infinite loop of unnecessary update attempts.
@nickmarden nickmarden merged commit 5b75892 into nickmarden:so-many-slashes Mar 31, 2026
@nickmarden
Copy link
Copy Markdown
Owner

Thanks @massawho - I needed these changes too for MyAccident as it turns out :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants