Skip to content

Fix #2 and #3; improve debugging a bit#4

Open
nickmarden wants to merge 13 commits intoubc:masterfrom
nickmarden:so-many-slashes
Open

Fix #2 and #3; improve debugging a bit#4
nickmarden wants to merge 13 commits intoubc:masterfrom
nickmarden:so-many-slashes

Conversation

@nickmarden
Copy link
Copy Markdown

@nickmarden nickmarden commented Feb 14, 2025

This was a small basket of fixes I needed to make to enable migration in an enterprise scenario:

  • I don't have (local CLI) Github login auth for the repos being transferred; I only have a token
  • I am moving repos into a nested project structure in Gitlab. The code previously expected a flat namespace name with no /
  • I want to be able to specify the visibility of the newly-created project in Gitlab
  • I needed better debugging help to see what was going wrong during my debugging
  • Various other bug fixes that arose from running the code under a more recent Python 3.x version

massawho and others added 6 commits March 16, 2026 15:49
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.
The groups API query used per_page=10000, which GitLab silently caps
at 100. On instances with more than 100 groups, the target namespace
may not appear in results, causing group_id to stay None and project
creation to fall back to the user's personal namespace.

Fix: add search= parameter using the leaf component of the namespace
so the API filters server-side, making pagination irrelevant.
Fix group lookup failing on large GitLab instances
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