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

bug: YAML parse error in config is silently swallowed, login overwrites all other contexts

Aperta Adatta ai principianti
#572 6 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@Sarthak-Shreshtha01 ci sta già lavorando.

Dal 8/10/2026.

  • #574 di @Sarthak-Shreshtha01 — aperta

Valutazione

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

Direzione di ricerca

Inizia da localconfig.go, intorno alla riga 103, e confronta come ReadLocalConfig e ReadLocalWatchConfig gestiscono gli errori di configUtil.UnmarshalLocalFile. Poi leggi config_test.go e aggiungi test per YAML non valido per entrambi i reader. Il lavoro è completato quando gli errori di parsing vengono restituiti invece di essere trattati come una configurazione vuota, mentre un file mancante continua a restituire nil, nil.

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

Descrizione

component/cli kind/bug

A tab instead of spaces — or any YAML syntax error — in the config file causes ReadLocalConfig to return an empty config with no error, making every command behave as if the user has never logged in.

The dangerous part: login sees the empty config, treats it as a fresh install, and writes a brand-new file over it. Every other context, server, user and refresh token in the file is gone with no warning.

Root cause

localconfig.go line 103:

err = configUtil.UnmarshalLocalFile(path, &config)
if os.IsNotExist(err) {
    return nil, nil
}
err = ValidateLocalConfig(config)  // parse error is silently overwritten here

Only os.IsNotExist is handled. A YAML parse error falls through and gets immediately overwritten by ValidateLocalConfig. Same bug in ReadLocalWatchConfig.

To reproduce

  1. Put a tab on any indented line in ~/.config/microcks/config
  2. Run microcks context → reports "no contexts defined" instead of a parse error
  3. Run microcks login <any-server> → the file is truncated and rewritten. All previous contexts are gone.

Fix

if err != nil {
    return nil, fmt.Errorf("reading config %s: %w", path, err)
}

Same in ReadLocalWatchConfig. After this, nil, nil keeps its only meaning — file doesn't exist — and fresh-install logic stays untouched.

There is no test for malformed input in config_test.go, which is how this went unnoticed.

Lingua principale
Go
Stelle
58
Fork
72
Merge medio
1g 11h
PR unite (30g)
27

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 microcks/microcks-cli

Tutte le issue di microcks/microcks-cli

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.