diag: resolve label IDs dynamically from Gitea API instead of hardcoding #134

Closed
opened 2026-03-23 23:41:17 +00:00 by kert · 0 comments
Owner

Problem

src/api/diag/__main__.py has 20 hardcoded label IDs (lines 23-52). If labels are recreated or the repo is cloned, all IDs break silently.

Fix

Add a resolve_labels(names: list[str]) -> list[int] helper to api.clients.gitea that:

  1. Fetches GET /repos/{owner}/{repo}/labels
  2. Builds a name→ID mapping (cached per process)
  3. Returns IDs for the requested label names

The diag reporter calls resolve_labels(['ci', 'pipeline:deploy', 'step:build', 'image:api']) instead of [13, 15, 22, 28].

Files

  • src/api/clients/gitea/client.py — add label resolution
  • src/api/diag/__main__.py — use name-based resolution
  • src/api/diag/vuln.py — same
## Problem `src/api/diag/__main__.py` has 20 hardcoded label IDs (lines 23-52). If labels are recreated or the repo is cloned, all IDs break silently. ## Fix Add a `resolve_labels(names: list[str]) -> list[int]` helper to `api.clients.gitea` that: 1. Fetches `GET /repos/{owner}/{repo}/labels` 2. Builds a name→ID mapping (cached per process) 3. Returns IDs for the requested label names The diag reporter calls `resolve_labels(['ci', 'pipeline:deploy', 'step:build', 'image:api'])` instead of `[13, 15, 22, 28]`. ## Files - `src/api/clients/gitea/client.py` — add label resolution - `src/api/diag/__main__.py` — use name-based resolution - `src/api/diag/vuln.py` — same
kert added this to the P18: Config Consolidation — eliminate hardcoded values milestone 2026-03-23 23:41:17 +00:00
kert added the apici labels 2026-03-23 23:41:17 +00:00
kert closed this issue 2026-03-23 23:51:30 +00:00
Sign in to join this conversation.