Config keys are hand-wired in five places with no completeness test

Ouverte
#189 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
4/5
Temps estimé
3-5 jours
Accessibilité débutants
58/100
Type d'issue
Refactorisation
Clarté
Clairement spécifiée
Activité
Active
Stack technique
go
Domaine
backend

Piste de recherche

Start with internal/config/config.go and the hand-picked tests in internal/config/config_test.go; trace how Config fields are merged and classified by untrust. Add reflection coverage that exercises every leaf field and a table that states each field’s treatment for working-directory config. Run make test-short (or .\make.ps1 test-short on Windows) and check make lint; done when both completeness tests fail for omissions and existing config tests pass.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

help wanted severity: medium tech-debt

Summary

A setting has to be added to the struct, the defaults, merge, untrust, Validate and often the flag loader. Nothing ties these together, and two of the possible omissions fail silently.

Where

  • internal/config/config.go:424 (untrust)
  • internal/config/config.go:544 (merge)
  • internal/config/config.go:703 (Validate)
  • internal/cli/flags.go:133 (globalFlags.load)
  • internal/config/config_test.go:51, :134 (tests with hand-picked keys)

Details

merge only copies the fields it names (119 lines, one if per field), so a new struct field that TOML decodes, and that therefore passes the unknown-key check, is accepted and silently ignored unless it is also added to merge. untrust is a per-key list of what a spackle.toml found in the working directory may not set, so a new key gets no decision unless someone remembers to make one. The two tests that cover this set a hand-picked list of keys; neither walks the struct. No key was found to be wrong today; this is about the next one.

Impact

internal/config/config.go and docs/config.md are among the most frequently changed files, so keys are added often. Each addition is a five-place edit where an omission in merge or untrust produces no error and no failing test.

Suggested fix

Incremental, each step leaves behavior unchanged. (1) Add a test that walks Config with reflection, builds the dotted path of every leaf field, writes a file that sets each to a non-default value, loads it and asserts every leaf differs from the default; this pins merge. (2) Add a table that classifies every leaf path as kept, dropped or capped for a working-directory file, fail when a leaf is missing from the table, and assert untrust matches it. (3) Optionally replace the per-field chain in merge with a reflection overlay plus the few explicit exceptions, only after 1 and 2 are green.

Acceptance criteria

  • A reflection test fails when a struct field is not merged
  • A table test fails when a field has no stated treatment for a working-directory config file
  • Existing config tests still pass unchanged

Related: #112

Getting started

  • Relevant files: internal/cli/flags.go, internal/config/config.go, internal/config/config_test.go
  • How to run tests: make test-short (Unix) or .\make.ps1 test-short (Windows PowerShell); make lint before you call it done
  • Related docs: docs/config.md, CONTRIBUTING.md

Filed by repo-audit/full-audit at 50e92ec. Severity: medium. Effort: M. audit-key: tech-debt|internal/config/config.go|merge-completeness

Langage dominant
Go
Étoiles
0
Forks
1
Merge moyen
8 h 14 min
PR mergées (30 j)
3

Préparer son environnement

Ouvrir dans Codespaces

Lance le conteneur de développement du projet dans votre navigateur, avec votre propre compte GitHub.

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de TMHSDigital/Spackle

Toutes les issues de TMHSDigital/Spackle

Issues similaires

Plus d'issues Go

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.