Localized git output defeats ErrNotRepo; stored runs refused outside a repo

Ouverte
#176 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é
3/5
Temps estimé
1-2 jours
Accessibilité débutants
78/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
git, go
Domaine
cli, tooling

Piste de recherche

Read internal/gitx/gitx.go, especially baseEnv and runEnv, then trace how internal/engine/engine.go handles ErrNotRepo. Start by running the relevant gitx tests and add coverage for LANGUAGE=de on a non-repository. Done when locale-pinned git calls return ErrNotRepo and spackle runs works with its state directory outside a repository; run make test-short and make lint.

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

Description

bug good first issue severity: medium

Summary

gitx recognizes "not a git repository" by matching English stderr text and does not pin the locale, so on a machine where git prints translated messages every command that reads stored runs is refused when the state directory is outside a repository.

Where

  • internal/gitx/gitx.go:370 (runEnv matches "not a git repository")
  • internal/gitx/gitx.go:376 (matches "lazy fetching disabled")
  • internal/gitx/gitx.go:71-93 (baseEnv sets no LC_ALL or LANGUAGE)
  • internal/engine/engine.go:166-172 (CheckStateDir refuses on any other error)
  • internal/cli/runs.go:111, internal/mcp/tools.go:702 (callers)

Details

baseEnv passes the operator's environment through and adds GIT_* variables only. git translates this message; with a German locale it reads "Kein Git-Repository ...". The error then falls through to the generic git rev-parse ... error, and CheckStateDir treats every TopLevel error that is not ErrNotRepo as "git cannot read the repository around " and returns a refusal.

Not reproduced on the audit machine: Git for Windows ships no translations. The code path was read end to end, and the message is a translated string in git builds with gettext (distribution packages on Linux, Homebrew on macOS).

Impact

On such a machine, for a scan of a plain directory, a live URL or a git URL run from a directory that is not a checkout, the scan works and creates the run, and then spackle runs, report, verify, baseline, runs compare, runs prune, scan --resume and the MCP tools list_runs, get_report, get_finding, compare_runs all fail with a message that tells the operator to fix a repository that does not exist. The other ErrNotRepo callers only lose a clearer message.

Steps to reproduce

  1. On Linux with the git translations installed: mkdir /tmp/plain && cd /tmp/plain && echo 'x=1' > a.py && spackle scan .
  2. LANG=de_DE.UTF-8 LANGUAGE=de spackle runs
  3. Expected: the run is listed. Actual: "git cannot read the repository around .spackle/runs", exit 3.

Suggested fix

Append LC_ALL=C and LANGUAGE=C in baseEnv (after dropping inherited values) so every message gitx parses is the untranslated one. Longer term, decide "not a repository" from git rev-parse --git-dir exit status, not stderr text.

Acceptance criteria

  • baseEnv pins the message locale
  • A test sets LANGUAGE=de and asserts TopLevel on a non-repository returns ErrNotRepo (skipped when git has no translations)
  • spackle runs works for a state directory outside any repository with LANG=de_DE.UTF-8

Getting started

  • Relevant files: internal/cli/runs.go, internal/engine/engine.go, internal/gitx/gitx.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: CONTRIBUTING.md, docs/ARCHITECTURE.md

Filed by repo-audit/full-audit at 50e92ec. Severity: medium. Effort: S. audit-key: bug|internal/gitx/gitx.go|runEnv

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.