fix: resolve label names to IDs in GiteaAdapter::createIssue

Gitea API expects label IDs (int64) not names. When string labels are
passed, resolve them via listLabels() before posting. Fixes 422
Unprocessable Entity errors that were causing tracking issue creation
to fail and repos to be marked as skipped during bulk sync.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jonathan Miller
2026-04-26 11:53:22 -05:00
parent 6795b72fec
commit 5c0cb98082
+16
View File
@@ -273,6 +273,22 @@ class GiteaAdapter implements GitPlatformAdapter
string $body = '',
array $options = []
): array {
// Gitea expects label IDs (int64), not names. Resolve if needed.
if (!empty($options['labels']) && is_string($options['labels'][0] ?? null)) {
$labelNames = $options['labels'];
$existing = $this->listLabels($org, $repo);
$nameToId = [];
foreach ($existing as $label) {
$nameToId[$label['name']] = $label['id'];
}
$options['labels'] = [];
foreach ($labelNames as $name) {
if (isset($nameToId[$name])) {
$options['labels'][] = $nameToId[$name];
}
}
}
$data = array_merge([
'title' => $title,
'body' => $body,