remove --preserve-state on a manifest-less hosted npm project silently restores the pin without the documented hosted_state_not_preservable note
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 2/5
- Tempo estimado
- 1-3 horas
- Facilidade para iniciantes
- 82/100
Direção de pesquisa
Comece em crates/socket-patch-cli/src/commands/remove.rs, em remove_hosted_only (por volta da linha 1337), e depois compare com o caminho hosted baseado em manifest por volta da linha 770. Reproduza remove --preserve-state no modo somente hosted, com e sem --json, e compare a saída com CLI_CONTRACT.md e rollback --preserve-state. Está concluído quando a observação hosted_state_not_preservable for exibida em ambos os modos de saída compatíveis.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
[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-stateprints 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 thehosted_state_not_preservablewarning". - Actual: the note is printed only on the manifest-backed
removepath. 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).
- Linguagem predominante
- Rust
- Estrelas
- 8
- Forks
- 0
- Merge médio
- 15h 39min
- PRs com merge (30d)
- 104
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Sem modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de SocketDev/socket-patch
-
agent:triaged bug bughunt pm:cargo priority:p2
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
SocketDev/socket-patch#651 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
agent:claimed agent:triaged arch-audit bug pm:hatch priority:p1
Dificuldade 2/5 Meio dia Facilidade para iniciantes 88/100
SocketDev/socket-patch#613 · 3 comentários ·
Mantenedores costumam responder em até 1 dia
-
agent:claimed agent:triaged arch-audit bug priority:p3
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
SocketDev/socket-patch#571 · 5 comentários ·
Mantenedores costumam responder em até 1 dia
-
agent:triaged bug bughunt pm:composer priority:p2
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 90/100
SocketDev/socket-patch#515 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
agent:triaged bug bughunt pm:npm priority:p1
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
SocketDev/socket-patch#464 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
Todas as issues de SocketDev/socket-patch
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 92/100
Mantenedores costumam responder em até 1 dia
-
Outdated docs on front pageAberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
rust-windowing/winit#4731 ·
Mantenedores costumam responder em até 2 dias
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mantenedores costumam responder em até 1 dia
-
area:cli bug priority:high
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 85/100
rtk-ai/rtk#4439 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
component:sight
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
agentic-os-org/ANOLISA#4622 · 1 comentário ·
Mantenedores costumam responder em até 1 dia