Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Core: duplicated leaf helpers — label sanitization and host matching

Aperta
#1,581 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
Mezza giornata
Idoneità per principianti
45/100
Tipo di issue
Refactoring
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
go
Ambito
backend

Direzione di ricerca

Start with the three identical label helpers (truncateLabel, sanitizeLabel, hasControlRunes) in core/cost/usage/usage.go and core/cost/ledger/row.go, plus the weaker variant in cmd/agentop/tui/usage_render.go, and pipeline.IsControlRune. Then compare the four matchesAnyHost copies in cpex/plugin.go, ibac/plugin.go, lineage/plugin.go and sparc/collect.go. Done means one shared sanitize/truncate helper and one hostmatch helper in core/plugins/internal, with existing tests still passing and the control-rune behaviour unchanged.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

What

Two leaf-helper families are copy-pasted across packages:

Label sanitization/truncation — 3 copies. truncateLabel, sanitizeLabel, hasControlRunes have byte-identical bodies in core/cost/usage/usage.go:1569-1662 and core/cost/ledger/row.go:210-304 (~45 lines each; only the comments differ). cmd/agentop/tui/usage_render.go:687 has a third, weaker variant (C0/DEL only). The rune predicate was already extracted (pipeline.IsControlRune, imported by both cost packages) — row.go:256 explicitly says the rule was extracted but the loops were not.

Host matching — 4 copies. matchesAnyHost (identical port-strip + path.Match glob) at cpex/plugin.go:460, ibac/plugin.go:572, lineage/plugin.go:789, sparc/collect.go:148.

Fix

SanitizeLabel/TruncateLabel beside pipeline.IsControlRune (or a tiny leaf), with each package keeping its policy comments and thin wrappers; one hostmatch helper in core/plugins/internal. ~130 lines deleted and the stored-vs-rendered control-rune handling stops differing.

Found in the 2026-10-29 structural audit of code organization.

Lingua principale
Go
Stelle
21
Fork
43
Merge medio
13h 8m
PR unite (30g)
267

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di rossoctl/cortex

Tutte le issue di rossoctl/cortex

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.