Importing issues from GitLab#31
Conversation
nickopris
left a comment
There was a problem hiding this comment.
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), |
There was a problem hiding this comment.
No default on switch and so $url_string can be undefined.
There was a problem hiding this comment.
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) andIssueImportOrchestrationService(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
$$configis a variable-variable and will trigger a fatal error here; this call should pass the loaded$configentity.
web/modules/custom/ai_dashboard/src/Service/IssueImportProcessService.php:540$contributorsis 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:
$ontributoris 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 placethrowoutside 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:1661createAssignmentRecords()iterates allassignee_idvalues but the Drupal.org mapper initializes$assignee_idto0, 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_statusis only applied when a timestamp filter is present because it's nested inside the$timestampblock. This breaks status-filtered imports without a date filter.
web/modules/custom/ai_dashboard/src/Service/IssueImportProcessService.php:1509 $current_paramsis 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:1640requestWithRetry()currently sleeps and retries on everyClientException(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:1650createCacheId()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:109BatchBuilderis referenced here but not imported in this file, which will cause a fatal error. Either add ause 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_processedare 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.
| 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; | ||
| } |
| 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; | ||
| } |
There was a problem hiding this comment.
I mentioned this one above.
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:
Generate an api token for GitLab, if you do not have one already. This can be done in your git.drupalcode.org account.
At the bottom of web\sites\default\settings.php, write:
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).
Run
The issues will now be loaded from GitLab instead of Drupal.org.