Flaky TestGetPrivateKeyPEM in pkg/router due to direct deep equal assertion on rsa.PrivateKey

Aperta Adatta ai principianti
#348 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@0xA8hinav ci sta già lavorando.

Dal 13/5/2026.

  • #331 di @0xA8hinav — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Tranquilla
Stack tecnologico
go
Ambito
testing-qa

Direzione di ricerca

Inizia con TestGetPrivateKeyPEM in pkg/router/jwt_test.go ed esegui il ciclo fornito per osservare il fallimento intermittente. Confronta i campi delle chiavi RSA generata e analizzata e rendi il test deterministico per chiavi matematicamente identiche; il lavoro è completato quando il test passa in modo affidabile durante esecuzioni ripetute e in CI.

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

Descrizione

kind/bug

What happened:
The unit test TestGetPrivateKeyPEM in pkg/router/jwt_test.go randomly fails in CI pipelines (such as the test-coverage check job) even when there are no changes to the JWT or router logic.

The test fails at the assertion assert.Equal(t, manager.privateKey, privateKey) with a diff showing key component byte slices (specifically dQ or Dp) mismatching in length. For example, the original key's precomputed dQ has a length of 128 bytes, but the parsed key's dQ has a length of 127 bytes.

What you expected to happen:
The unit tests should be reliable and deterministic. The test should succeed as long as the generated and parsed RSA keys are mathematically identical (i.e. possess the same E, N, D, and Primes), regardless of minor byte slice formatting or precomputation padding details during ASN.1 serialization/deserialization.

How to reproduce it (as minimally and precisely as possible):
Since the test relies on random key generation (rsa.GenerateKey), it fails sporadically. You can reproduce it locally by running the test in a loop:

for i in {1..200}; do go test -v -run TestGetPrivateKeyPEM ./pkg/router/... || exit 1; done

Lingua principale
Go
Stelle
176
Fork
95
Merge medio
5g 18h
PR unite (30g)
9

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 volcano-sh/agentcube

Tutte le issue di volcano-sh/agentcube

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.