Integer parameters equal to 2^63 pass the range check in toInt and wrap to a negative number
Los mantenedores suelen responder en 4 días
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 82/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- go
- Área
- backend-api-design
Línea de trabajo
Empieza con toInt en pkg/github/params.go e inspecciona las pruebas existentes de toInt en pkg/github. Ejecuta go test ./pkg/github para ver la cobertura actual y luego añade casos límite alrededor de 2^63. Verifica que devuelvan el error de rango documentado y que los valores válidos dentro del rango sigan convirtiéndose.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Describe the bug
toInt in pkg/github/params.go is documented to reject "values outside the int range", but its upper bound check compares against math.MaxInt as a float:
if f > math.MaxInt || f < math.MinInt {
return 0, fmt.Errorf("numeric value out of int range: %v", f)
}
return int(f), nil
math.MaxInt (2^63 - 1) cannot be represented as a float64 and rounds up to exactly 2^63. A value of 2^63 is therefore not greater than the bound, passes the check, and int(f) on an out-of-range float is implementation-defined in Go. On amd64 it produces math.MinInt (-9223372036854775808).
Any value that parses to 2^63, including the integer 9223372036854775807 itself, is accepted without an error and becomes a large negative number. This affects every tool that reads integers through RequiredInt, OptionalIntParam, OptionalIntParamWithDefault and OptionalPaginationParams (for example issue_number, pull_number, page, perPage). toInt64 is not affected because it uses a round-trip check.
Affected version
main at 07e2466, built from source (Go toolchain from go.mod, linux/amd64).
Steps to reproduce the behavior
-
Add this test to
pkg/github:package github import "testing" func TestToIntUpperBound(t *testing.T) { for _, v := range []any{"9223372036854775807", float64(9223372036854775807), "9223372036854775808", "1e19"} { n, err := OptionalIntParam(map[string]any{"pull_number": v}, "pull_number") t.Logf("%v -> %d, err=%v", v, n, err) } } -
Run
go test ./pkg/github -run TestToIntUpperBound -v.
Expected vs actual behavior
Expected: every value at or above 2^63 is rejected with numeric value out of int range, as 1e19 already is.
Actual:
9223372036854775807 -> -9223372036854775808, err=<nil>
9.223372036854776e+18 -> -9223372036854775808, err=<nil>
9223372036854775808 -> -9223372036854775808, err=<nil>
1e19 -> 0, err=parameter pull_number is not a valid number: numeric value out of int range: 1e+19
The negative value is then sent on to the GitHub API (for example as a pull request number or page) instead of being rejected locally with a clear parameter error.
Logs
Not applicable; the output above is from the test.
Possible Solution
- Make the upper bound exclusive at 2^63 (
f >= -float64(math.MinInt)), or reuse the round-trip check thattoInt64already performs. - Add the boundary values above to the existing
toInttests.
if f >= -float64(math.MinInt) || f < float64(math.MinInt) {
return 0, fmt.Errorf("numeric value out of int range: %v", f)
}
return int(f), nil
I'm happy to send a PR.
- Lenguaje dominante
- Go
- Estrellas
- 33.4k
- Forks
- 5.1k
- Merge medio
- 2 d 10 h
- PR fusionados (30 d)
- 35
Preparar el entorno
- Incluye un Dockerfile o un 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 github/github-mcp-server
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
github/github-mcp-server#3475 ·
Los mantenedores suelen responder en 4 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
github/github-mcp-server#3450 ·
Los mantenedores suelen responder en 4 días
-
request ai review
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
github/github-mcp-server#3439 ·
Los mantenedores suelen responder en 4 días
-
get_job_logs with failed_only misses failed jobs after the first 30 jobs of a runPosiblemente ocupada @jayhemnani9910 la tomó hace 7 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
github/github-mcp-server#3428 ·
Los mantenedores suelen responder en 4 días
-
create_or_update_file writes to the wrong file when the path contains # or ?Posiblemente ocupada @jayhemnani9910 la tomó hace 7 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
github/github-mcp-server#3427 ·
Los mantenedores suelen responder en 4 días
Todos los issues de github/github-mcp-server
Issues similares
-
docs: namespaceRegexes example teaches prefix matching, but regexes are matched as a substringAbiertotriage/pending-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
external-secrets/external-secrets#7117 ·
Los mantenedores suelen responder en 2 días
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
ENTERPILOT/GoModel#1183 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
enhancement good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Edwin-metcalf/MetCode#16 ·
-
Action Required: Fix Renovate ConfigurationPosiblemente ocupada @thompson-tomo la tomó hoy. Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 78/100
open-telemetry/opentelemetry-collector#16170 ·
Los mantenedores suelen responder en 1 día
-
Buffer.writeRTX drops the RTCP returned by calc, so NACKs for other lost packets are never sentAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Los mantenedores suelen responder en 1 día