Hacktoberfest 2026 : les issues que les mainteneurs ont marquées pour octobre, ouvertes et accessibles aux débutants. Parcourir les issues Hacktoberfest

remove --preserve-state on a manifest-less hosted npm project silently restores the pin without the documented hosted_state_not_preservable note

Ouverte Adaptée aux débutants
#433 1 commentaire 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é
2/5
Temps estimé
1-3 heures
Accessibilité débutants
82/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
rust
Domaine
cli

Piste de recherche

Commencez dans crates/socket-patch-cli/src/commands/remove.rs, au niveau de remove_hosted_only (vers la ligne 1337), puis comparez-le avec le chemin hosted basé sur le manifest vers la ligne 770. Reproduisez remove --preserve-state en mode hosted uniquement, avec et sans --json, puis comparez la sortie avec CLI_CONTRACT.md et rollback --preserve-state. Le travail est terminé lorsque la note hosted_state_not_preservable est affichée dans les deux modes de sortie pris en charge.

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

Description

agent:triaged bug bughunt pm:npm priority:p1

[agent] Found by the scheduled npm bug-hunt routine (ledger #302).

Summary

In v5, a project patched by a bare scan (hosted mode) has no .socket/manifest.json. On such a project, socket-patch remove <purl> --preserve-state restores the hosted pin to the upstream registry and deletes the .npmrc. So the patch is gone, even though the user asked to preserve state.

The command never tells the user this. There's no "hosted wiring has no preservable local state" note on stderr, and no warnings[] in --json (the envelope has no warnings key at all). rollback --preserve-state on the same project correctly emits hosted_state_not_preservable.

Severity is low. The behaviour (restoring anyway) is what's documented; only the advisory is missing. But --preserve-state exists so the user can expect to re-apply later, and here it silently doesn't preserve.

Repro (Linux, npm 12.1.0, main 2463257)

A local mock of the patch API serves pkg:npm/[email protected]. SPA="--api-url … --org o --api-token fake --patch-server-url …".

echo '{"name":"t","version":"1.0.0","private":true,"dependencies":{"left-pad":"1.3.0"}}' > package.json
npm install
socket-patch scan $SPA                                    # hosted: package-lock.json + .npmrc rewritten, no .socket/
socket-patch remove pkg:npm/[email protected] --preserve-state $SPA
#   The following hosted patch will be unwound and removed:
#     - pkg:npm/[email protected]
#   Restored pkg:npm/[email protected] to its upstream registry entry
#   (no "no preservable local state" note)
socket-patch scan $SPA
socket-patch remove pkg:npm/[email protected] --preserve-state $SPA --json   # status success, events[hosted_reverted], no warnings key
socket-patch scan $SPA
socket-patch rollback --preserve-state $SPA --json        # warnings: [reinstall_required, hosted_state_not_preservable]  <- correct

It reproduces on 2 of 2 runs.

Expected vs actual

  • Expected: CLI_CONTRACT.md's warning table, row hosted_state_not_preservable, says: "rollback --preserve-state (v5.0): hosted pins were restored to upstream anyway … (remove --preserve-state prints the same note on stderr.)". The --preserve-state (opt-out, both rollback and remove) section says the same: "a preserve run still restores them to upstream — surfaced as the hosted_state_not_preservable warning".
  • Actual: the note is printed only on the manifest-backed remove path. The hosted-only path, which is the default v5 shape, prints nothing.
Project shape remove --preserve-state note
Hosted-only (no manifest), Linux npm 12.1.0 missing (stderr and JSON)
rollback --preserve-state, same project present

Suspect code

crates/socket-patch-cli/src/commands/remove.rs:1337 (remove_hosted_only). Its doc comment says "--preserve-state still unwinds — hosted has no preservable local state". But the Note: hosted wiring has no preservable local state … eprintln only exists in the manifest-backed hosted leg (remove.rs:770).

Langage dominant
Rust
Étoiles
8
Forks
0
Merge moyen
18 h 4 min
PR mergées (30 j)
70

Préparer son environnement

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 SocketDev/socket-patch

Toutes les issues de SocketDev/socket-patch

Issues similaires

Plus d'issues Rust

Recevez les nouvelles issues par e-mail

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