[BUG] npm pkg delete removes the first array item for a nonexistent property
Los mantenedores suelen responder en 2 días
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 83/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- javascript, node.js
- Área
- cli
Línea de trabajo
El issue apunta a lib/utils/queryable.js, especialmente a la ruta de borrado en las líneas 197–204. Lee ese código y sigue cómo Queryable.delete() gestiona una clave de cadena cuando su elemento padre es un array; compáralo con el comportamiento indicado de keywords[1]. El trabajo estará terminado cuando borrar una propiedad inexistente del array lo deje sin cambios o rechace la ruta sin guardar, mientras que el borrado de un índice válido siga funcionando.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
is there an existing issue for this?
- I have searched the existing issues
this issue exists in the latest npm version
- I am using the latest npm
this is not just a request to bump a dependency for a CVE
- This is not solely a request to bump a dependency for a CVE
current behavior
npm pkg delete keywords.missing removes the first keyword.. even though there is no missing property. the command exits 0 without a warning.
with "keywords": ["alpha", "beta"], the result is "keywords": ["beta"].
keywords.beta does the same thing.. it removes "alpha", not the value named "beta". contributors.missing also removes the first contributor when contributors is an array of objects.
expected behavior
a nonexistent property should not cause an unrelated array item to be deleted.. either leave the array unchanged or reject the path without saving changes.
steps to reproduce
mkdir npm-pkg-delete-repro
cd npm-pkg-delete-repro
echo '{"name":"pkg-delete-repro","version":"1.0.0","keywords":["alpha","beta"]}' > package.json
npm pkg delete keywords.missing
cat package.json
result:
{
"name": "pkg-delete-repro",
"version": "1.0.0",
"keywords": [
"beta"
]
}
resetting the fixture and running npm pkg delete 'keywords[1]' correctly removes "beta". deleting a missing property from an object.. such as scripts.missing.. leaves its existing properties alone.
in lib/utils/queryable.js, the delete path calls _data.splice(_key, 1) whenever the parent is an array. a nonnumeric key remains a string.. splice() coerces it to NaN and treats that as index 0.
environment
- npm: 12.2.0, the current
latestregistry tag - Node.js: v24.21.0
- macOS 26.4, arm64
- reproduced with empty user and global npm config files
also reproduced with npm 11.19.0. the current latest branch's Queryable.delete() reproduces it directly too.. checked at ae98c62586b6fea44114f72e249e246a2981de70.
- Lenguaje dominante
- JavaScript
- Estrellas
- 10.2k
- Forks
- 4.9k
- Merge medio
- 5 d 4 h
- PR fusionados (30 d)
- 17
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de npm/cli
-
[BUG] Windows: EEXIST on bin shims that npm wrote itself (bundled read-cmd-shim 7.0.0 cannot read the $basedir_win shims of cmd-shim 9.0.2)Posiblemente ocupada @martinrrm la tomó hoy. AbiertoPriority 2
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
Los mantenedores suelen responder en 2 días
-
create node pr: Node.js 20 deprecation & `DEP0040` warnings loggedPosiblemente ocupada @lazerg la tomó hace 27 días. AbiertoEngineering Priority 1
Dificultad 1/5 Menos de una hora Aptitud para principiantes 80/100
Los mantenedores suelen responder en 2 días
-
Engineering Priority 2
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
npm/cli#10020 · 1 comentario ·
Los mantenedores suelen responder en 2 días
-
`npm audit signatures` does not report how many packages it skipped for want of registry keysPosiblemente ocupada @greenlincoln05 la tomó hace 23 días. AbiertoPriority 3
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
npm/cli#10018 · 2 comentarios ·
Los mantenedores suelen responder en 2 días
-
[BUG] E401 error message does not use the configured registryPosiblemente ocupada @toufiq-dev la tomó hace 26 días. AbiertoBug Priority 3
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
npm/cli#10014 · 1 comentario ·
Los mantenedores suelen responder en 2 días
Issues similares
-
전문가 노하우 케이스 형식에 재검토 시점을 필수로 둔다Abiertodocs
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
idean3885/claude-ops-agent#765 ·
Los mantenedores suelen responder en 1 día
-
Edit: Al Janoubiya TV SDAbiertocheck:failed feeds:edit
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
iptv-org/database#38385 · 1 comentario ·
Los mantenedores suelen responder en 6 días
-
release-followup
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
Workspace secrets/constants containing "$" are corrupted when resolved in data source optionsAbiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
Los mantenedores suelen responder en 1 día
-
[BUG]: percentTotal not shown as percentagePosiblemente ocupada @ORITOMI la tomó hoy. Abiertobug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 93/100
Los mantenedores suelen responder en 2 días