Emit --json error envelopes through one json_envelope::emit_error: the builder is written 5 times and the human branch drifted
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
- 55/100
Piste de recherche
Start in crates/socket-patch-cli/src/json_envelope.rs around usage_error_json and usage_error (L669-L700), then compare the duplicates in commands/lock_cli.rs (error_envelope), commands/rollback.rs, commands/remove.rs (emit_error_envelope) and commands/scan/hosted.rs. Run the usage_error_json tests and the manifest_not_found tests first to pin current output. Done when one json_envelope::emit_error helper replaces the duplicates, --json output is byte-identical, and only the usage_error human line changes to sentence case.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
[agent] Filed by the scheduled architecture audit (audit-cli-tests). Register: T20.
Kind: refactor. Register ID: T20.
Problem
"Build an Envelope with status: error, print it under --json, else print Error: … to stderr" has no shared helper. It is written out in five places at cbbbdb9:
- json_envelope.rs L669-L700:
usage_error_json+usage_error. It hand-writesprintln!+to_string_prettyinstead ofui::print_json, and printsError: {message}raw. - lock_cli.rs L191-L201:
error_envelope, plusemit. The human branch adds a hint. - rollback.rs L903-L908: its own
error_envelope. rollback also open-codes 4 more branches beside it. - remove.rs L122-L132:
emit_error_envelope. The human branch sentence-cases the message. - scan/hosted.rs L80-L91:
json_error_envelope. It starts from a partial scan envelope, which is legitimately different.
The same pattern is also hand-written in repair.rs (L78, L143, L257), list.rs L219 and scan/mod.rs L1530.
The function bodies are identical: Envelope::new(cmd), set dry_run, then mark_error(EnvelopeError::new(code, msg)). The human branch has drifted three ways:
usage_errorprints the message raw;- remove sentence-cases it;
- lock_cli appends a hint.
// remove.rs
let mut env = Envelope::new(Command::Remove);
env.dry_run = dry_run;
env.mark_error(EnvelopeError::new(code, message));
println!("{}", env.to_pretty_json());
} else { eprintln!("Error: {}", crate::ui::sentence_case(&message)); }
Proposed change
- Add
Envelope::error(command, dry_run, EnvelopeError) -> Envelopeinjson_envelope.rs. - Add
json_envelope::emit_error(command, json, dry_run, EnvelopeError). It prints withui::print_jsonunder--json; otherwise it printsError: {sentence_case(message)}to stderr. - Make
usage_errorcallemit_errorand return 2. - Delete
lock_cli::error_envelope,rollback::error_envelopeandremove::emit_error_envelope, and call the helper from repair, list and scan. - lock_cli keeps its hint as a second
eprintln!.
Size
About 8 files, roughly -60/+25 lines.
Acceptance criteria
- Every
--jsonerror document is byte-identical to today's. These guard it:- the
usage_error_jsontests injson_envelope.rs; - the lock_cli
error_envelopetests; - the rollback/remove
manifest_not_foundtests; tests/common/envelope.rsusers.
- the
usage_error's human line becomes sentence-cased. That is the one intended human-text change; say so in the PR.- No
Envelope::new(..)followed bymark_errorremains outsidejson_envelope.rs, except scan's partial-envelope case.
- Langage dominant
- Rust
- Étoiles
- 9
- Forks
- 2
- Merge moyen
- 1 j 8 h
- PR mergées (30 j)
- 309
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Aucun modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de SocketDev/socket-patch
-
Windows unit tests fail on main: pnpm-registry-overrides fixtures are checked out as CRLF (mixes CRLF and LF line endings)Peut-être pris @mikolalysenko l’a pris aujourd’hui. Ouverteagent:claimed agent:triaged ci-janitor priority:p1
Difficulté 1/5 1-3 heures Accessibilité débutants 85/100
SocketDev/socket-patch#2238 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
agent:triaged arch-audit priority:p3 refactor
Difficulté 2/5 1-3 heures Accessibilité débutants 83/100
SocketDev/socket-patch#1860 ·
Les mainteneurs répondent en général sous 1 jour
-
agent:triaged arch-audit priority:p3 refactor
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
SocketDev/socket-patch#1838 ·
Les mainteneurs répondent en général sous 1 jour
-
Nightly: pnpm11_registry_route_is_cleaned_up_when_a_patch_is_not_needed fails on Windows (pnpm records the RUNNER~1 short path as a second importer)Peut-être pris Une pull request liée à cette issue est ouverte ou déjà fusionnée. Ouverteagent:triaged ci-janitor priority:p1
Difficulté 3/5 Une demi-journée Accessibilité débutants 42/100
SocketDev/socket-patch#2235 ·
Les mainteneurs répondent en général sous 1 jour
-
Agent mode reports a gem whose installed file was edited as "not installed on this host" / "not found on disk", `apply --check` says to run `apply`, and `rollback` exits 1 with "modified after patching" on every runPeut-être pris @mikolalysenko l’a pris aujourd’hui. Ouverteagent:claimed agent:triaged bug bughunt pm:bundler priority:p1 ux
Difficulté 4/5 3-5 jours Accessibilité débutants 18/100
SocketDev/socket-patch#2231 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de SocketDev/socket-patch
Issues similaires
-
area: cli good first issue type: feature
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
-
[Bug] Windows Ghidra provider rejects a PATH-only JDK: bare `java.exe` probe fails with Win32 87Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
Les mainteneurs répondent en général sous 1 jour
-
renaming a provider to a taken name fails with a raw sql errorPeut-être pris Une pull request liée à cette issue est ouverte ou déjà fusionnée. Ouvertearea:storage kind:bug priority:p3 ready
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
Les mainteneurs répondent en général sous 1 jour
-
bug bugfix
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
storytold/photocraft#16975 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
expo/exact#1716 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour