Skip to content

Importing issues from GitLab#31

Open
MxLourier wants to merge 17 commits into
FreelyGive:mainfrom
WiseTrout:feature/gitlab-issue-import
Open

Importing issues from GitLab#31
MxLourier wants to merge 17 commits into
FreelyGive:mainfrom
WiseTrout:feature/gitlab-issue-import

Conversation

@MxLourier

Copy link
Copy Markdown
Contributor

This PR aims to allow the import of AI issues not just from Drupal.org, but also from git.drupalcode.org.

To make it work:

  1. Generate an api token for GitLab, if you do not have one already. This can be done in your git.drupalcode.org account.

  2. At the bottom of web\sites\default\settings.php, write:

$settings['gitlab_api_token'] = "..." // Insert token generated for git.drupalcode.org
  1. Create/update an import config entity with source type GitLab. For example, ai_translate project has been moved to GitLab, so the corresponding import config entity can be edited. Make sure to also edit the project id (this can be found on the project page on git.drupalcode.org).

  2. Run

ddev drush ai-dashboard:import ai_translate

The issues will now be loaded from GitLab instead of Drupal.org.

@nickopris nickopris left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a basic code review. I requested Copilot to have a go as well. I haven't actually tested the functionality.

'#type' => 'link',
'#title' => $machine_name,
'#url' => Url::fromUri("https://www.drupal.org/project/{$machine_name}"),
'#url' => Url::fromUri($url_string),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No default on switch and so $url_string can be undefined.

Comment thread web/modules/custom/ai_dashboard/src/Form/ModuleImportForm.php Outdated
Comment thread web/modules/custom/ai_dashboard/src/Form/ModuleImportBulkForm.php Outdated
Comment thread web/modules/custom/ai_dashboard/src/Form/ModuleImportBulkForm.php Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the AI Dashboard issue importer to support GitLab (git.drupalcode.org) in addition to Drupal.org by introducing a source-aware import process service and a separate orchestration/batch service, then wiring those into the UI, Drush commands, and queue worker.

Changes:

  • Added GitLab API integration (token via $settings['gitlab_api_token']) and GitLab issue mapping alongside Drupal.org mapping.
  • Refactored import logic into IssueImportProcessService (API fetching + issue processing) and IssueImportOrchestrationService (batch orchestration, multi-status handling).
  • Updated admin UI list links/CSS and rewired service registrations and call sites to the new services.

Reviewed changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
web/modules/custom/ai_dashboard/src/Service/IssueImportProcessService.php Implements source-specific API requests (Drupal.org/GitLab), mapping, pagination, and assignment creation.
web/modules/custom/ai_dashboard/src/Service/IssueImportOrchestrationService.php Introduces orchestration/batch logic and multi-status handling for imports.
web/modules/custom/ai_dashboard/src/Plugin/QueueWorker/ModuleImportFullSync.php Updates queue worker to use the new process service.
web/modules/custom/ai_dashboard/src/ModuleImportListBuilder.php Adds GitLab project links in the module import listing.
web/modules/custom/ai_dashboard/src/Form/ModuleImportForm.php Updates machine-name-to-project-id resolution to use the new process service.
web/modules/custom/ai_dashboard/src/Form/ModuleImportBulkForm.php Rewires bulk import actions to the new orchestration service.
web/modules/custom/ai_dashboard/src/Drush/Commands/AiDashboardCommands.php Rewires Drush import command to use the new process service and source-aware timestamps.
web/modules/custom/ai_dashboard/src/Controller/ImportAdminController.php Rewires admin import actions to the new services.
web/modules/custom/ai_dashboard/css/bulk-operations.css Extends link styling to GitLab URLs.
web/modules/custom/ai_dashboard/ai_dashboard.services.yml Registers the new process/orchestration services and updates dependencies.
.gitignore Adds DDEV phpMyAdmin files/private directory to ignore list.
Comments suppressed due to low confidence (15)

web/modules/custom/ai_dashboard/src/Service/IssueImportOrchestrationService.php:457

  • $$config is a variable-variable and will trigger a fatal error here; this call should pass the loaded $config entity.
    web/modules/custom/ai_dashboard/src/Service/IssueImportProcessService.php:540
  • $contributors is declared as a static variable but never initialized as an array. Accessing $contributors[$do_username] below will raise warnings/errors. Initialize the static cache to an empty array like the Drupal.org mapping does.
    web/modules/custom/ai_dashboard/src/Service/IssueImportProcessService.php:572
  • Accessing $contributors[$do_username] without checking if the key exists will emit a notice and can break assignee mapping. Use the null-coalescing operator.
    web/modules/custom/ai_dashboard/src/Service/IssueImportProcessService.php:586
  • Typo: $ontributor is undefined, so this will throw and prevent GitLab assignees from being imported.
    web/modules/custom/ai_dashboard/src/Service/IssueImportProcessService.php:613
  • This is invalid method access ($do_assignee->get->get(...)) and will fatally error. Drupal field values can be read via $entity->get('field_name')->value (or ->getString() depending on need).
    web/modules/custom/ai_dashboard/src/Service/IssueImportProcessService.php:1310
  • resolveGitLabProjectIdFromMachineName() currently has (1) string concatenation using + (numeric addition in PHP) and (2) mismatched braces that place throw outside the method, causing a parse error. It also doesn't send the required GitLab auth token header.
    web/modules/custom/ai_dashboard/src/Service/IssueImportProcessService.php:1661
  • createAssignmentRecords() iterates all assignee_id values but the Drupal.org mapper initializes $assignee_id to 0, which becomes [0] and is treated as non-empty. This will attempt to create assignments for user ID 0. Skip falsy IDs.
    web/modules/custom/ai_dashboard/src/Service/IssueImportProcessService.php:1708
  • The error message refers to an environment variable, but the token is read from Drupal settings ($this->settings->get('gitlab_api_token')) and the PR instructions tell users to set $settings['gitlab_api_token']. This message will mislead users during setup.
    web/modules/custom/ai_dashboard/src/Service/IssueImportProcessService.php:1757
  • For Drupal.org requests, field_issue_status is only applied when a timestamp filter is present because it's nested inside the $timestamp block. This breaks status-filtered imports without a date filter.
    web/modules/custom/ai_dashboard/src/Service/IssueImportProcessService.php:1509
  • $current_params is computed for pagination but never used; requestWithRetry() is called with $params, so pagination parameters (page/per_page/limit) are not sent and the loop will keep re-fetching the same page.
    web/modules/custom/ai_dashboard/src/Service/IssueImportProcessService.php:1640
  • requestWithRetry() currently sleeps and retries on every ClientException (including 4xx like 404/401), which can cause long delays and hides the real failure reason. Only retry on 429, and otherwise break/return the error.
    web/modules/custom/ai_dashboard/src/Service/IssueImportProcessService.php:1650
  • createCacheId() doesn't include the module/project context. If two different modules from the same source have the same external issue number, the import-session cache can return the wrong node and update the wrong issue.
    web/modules/custom/ai_dashboard/src/Service/IssueImportOrchestrationService.php:109
  • BatchBuilder is referenced here but not imported in this file, which will cause a fatal error. Either add a use Drupal\Core\Batch\BatchBuilder; import or fully-qualify the class name.
    web/modules/custom/ai_dashboard/src/Service/IssueImportOrchestrationService.php:458
  • This method signature was changed to take $single_status, but the code later uses $status_name (which is no longer defined). That will trigger notices/fatal errors when setting the batch message / log context.
    web/modules/custom/ai_dashboard/src/Service/IssueImportOrchestrationService.php:399
  • $context['sandbox']['current_operation'] / total_processed are incremented without being initialized. On the first batch operation this will generate notices and can break progress tracking. Initialize sandbox counters before incrementing.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +63 to 67
public function __construct(EntityTypeManagerInterface $entity_type_manager, IssueImportProcessService $issue_process_service, IssueImportOrchestrationService $issue_orchestration_service, MessengerInterface $messenger) {
$this->entityTypeManager = $entity_type_manager;
$this->importService = $import_service;
$this->issueProcessService = $issue_process_service;
$this->messenger = $messenger;
}
Comment thread web/modules/custom/ai_dashboard/src/Controller/ImportAdminController.php Outdated
Comment thread web/modules/custom/ai_dashboard/src/Controller/ImportAdminController.php Outdated
Comment thread web/modules/custom/ai_dashboard/src/Controller/ImportAdminController.php Outdated
Comment thread web/modules/custom/ai_dashboard/src/Controller/ImportAdminController.php Outdated
Comment thread web/modules/custom/ai_dashboard/src/Form/ModuleImportBulkForm.php Outdated
Comment on lines +65 to +72
switch ($source_type) {
case 'drupal_org':
$url_string = "https://www.drupal.org/project/{$machine_name}";
break;
case 'gitlab':
$url_string = "https://git.drupalcode.org/project/${machine_name}";
break;
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mentioned this one above.

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.

4 participants