From 5c0cb980822c88ca319e59178c26bccdc11ddafd Mon Sep 17 00:00:00 2001 From: Jonathan Miller Date: Sun, 26 Apr 2026 11:53:22 -0500 Subject: [PATCH] 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) --- lib/Enterprise/GiteaAdapter.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/Enterprise/GiteaAdapter.php b/lib/Enterprise/GiteaAdapter.php index 1fc5d00..5aa9699 100644 --- a/lib/Enterprise/GiteaAdapter.php +++ b/lib/Enterprise/GiteaAdapter.php @@ -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,