fix: node --line wraps a value above the int32 range and selects the wrong definition
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 80/100
Línea de trabajo
Lee internal/cli/node.go:91, donde --line se declara como int, luego el paso directo en las líneas 38-40, y internal/query/node.go:287, donde se convierte a int32 antes de la comparación de StartLine/EndLine en la línea 294. Añade una comprobación de rango (1 a 2147483647) ya sea en el flag o en el límite de la consulta, devolviendo un error que nombre el rango; no intentes hacer que narrowNodeMatches devuelva vacío. Extiende internal/query/node_test.go junto a TestNarrowNeverEmpty con un caso fuera de rango. Hecho significa que un valor fuera de rango da error en lugar de desbordarse.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
What happens
codegraph node --line converts the flag value to int32 with no range check. A value above the int32 range wraps around and selects the wrong definition.
The source shows the path:
internal/cli/node.go:91declares--lineas anint. When the value is not 0, lines 38-40 pass the pointer on.internal/query/node.go:287runsline := int32(*lineHint).internal/query/node.go:294compares that value withStartLineandEndLine, which areint32(internal/schema/graph.pb.go:112-113).- When no definition contains the line,
internal/query/node.go:301-303picks the nearest definition.
Reading the code gives these results. The binary was not run.
--line 4294967302(2^32 + 6) becomes6and selects the definition at line 6.--line 4294967296(2^32) becomes0. The pointer is not nil, so the nearest-line path picks one definition.--line 0shows all definitions.- Values from
2147483648(2^31) upward wrap to negative numbers.
Neither caller, NodeSelected (internal/query/node.go:378) nor NodeDetailSelected (internal/query/detail.go:307), checks the range.
What you expected instead
The command must return an error for a line outside 1 to 2147483647. The error must name that range.
An empty result is not the fix. narrowNodeMatches never returns an empty set by design (internal/query/node.go:266-268), so the check belongs at the flag or query boundary.
Steps to reproduce
Not run. These steps follow from the code and need a check on a built binary.
cd <repo>where a symbol has two or more definitions.- Run
codegraph node <symbol> --line 4294967302. - Run
codegraph node <symbol> --line 6. If the definition at line 6 is the same, both commands print it.
Version
Not run on a built binary. The source was read at main commit f17af677, after tag v0.19.2.
Platform
Not applicable. The defect is in flag handling, found by reading the source.
How did you install it?
Other
Languages in the affected repository
Not applicable. The bug is in --line handling, not in per-language extraction.
Before submitting
- I searched existing issues and this is not a duplicate
- I checked the capability matrix and this is not a documented limitation
- This is not a security vulnerability
Related: the node-only-line-flag proposal (#350, for #323) listed the 32-bit overflow as out of scope. The spec for --line (openspec/specs/graph-queries/spec.md:228-245) states no range.
Tests: TestNarrowNeverEmpty (internal/query/node_test.go:204) uses lines 22 and 35. TestLineFlagOnlyOnNode (internal/cli/overloads_cli_test.go:49) checks only which commands have the flag. No test covers an out-of-range value.
- Lenguaje dominante
- Go
- Estrellas
- 0
- Forks
- 0
- Merge medio
- 7 h 42 min
- PR fusionados (30 d)
- 111
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una 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 seanb4t/codegraph-go
-
chore needs-triage
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
seanb4t/codegraph-go#380 ·
Los mantenedores suelen responder en 1 día
-
chore needs-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
seanb4t/codegraph-go#379 ·
Los mantenedores suelen responder en 1 día
-
area:query chore needs-triage spec-needed
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
seanb4t/codegraph-go#377 ·
Los mantenedores suelen responder en 1 día
-
chore needs-triage
Dificultad 1/5 1-3 horas Aptitud para principiantes 84/100
seanb4t/codegraph-go#362 ·
Los mantenedores suelen responder en 1 día
-
area:ci chore priority:low
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
seanb4t/codegraph-go#329 ·
Los mantenedores suelen responder en 1 día
Todos los issues de seanb4t/codegraph-go
Issues similares
-
Add iterate GmbH domains to a dedicated list and include it in company and developer categoriesAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
v2fly/domain-list-community#4307 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
Los mantenedores suelen responder en 1 día
-
notify: voice_queue rows are deleted only at startup, so a hub that stays up grows it without boundAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
mattabate/life-distributable#232 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 86/100
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 83/100
Los mantenedores suelen responder en 1 día