GitHub.resolveToken: explicit tokenEnv pointing at an unset env var silently sends unauthenticated requests
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 76/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Tranquilo
- Stack tecnológico
- github, gitlab, typescript
Línea de trabajo
Comienza en src/prompt-generators/github/github.ts, en resolveToken y el flujo del constructor/searchIssues de GitHub; después, compara la lógica correspondiente en src/prompt-generators/gitlab/gitlab.ts. Verifica que una variable de entorno faltante o vacía nombrada explícitamente produzca un error claro, mientras que el comportamiento de fallback existente permanezca sin cambios cuando se omite tokenEnv.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Observed behavior
resolveToken in src/prompt-generators/github/github.ts returns the value of process.env[options.tokenEnv] whenever tokenEnv is set, without checking whether that variable actually has a value:
function resolveToken(options: GitHubConstructorOptions): string | undefined {
if (options.token !== undefined) {
return options.token;
}
if (options.tokenEnv !== undefined) {
return process.env[options.tokenEnv];
}
return process.env['GITHUB_TOKEN'] ?? process.env['GH_TOKEN'];
}
If the user explicitly configures tokenEnv: 'CI_GITHUB_TOKEN' in a JSON config (the recommended path for storing tokens out of files) but the environment variable is missing or empty, process.env[options.tokenEnv] returns undefined. The constructor then sets this.#token = undefined, and searchIssues proceeds to call the GitHub API anonymously, hitting the much smaller unauthenticated rate limit (60 requests/hour shared per IP, with search subject to even tighter limits).
The user receives no signal that their token was not picked up. The first symptom is usually a 403 rate limit exceeded from GitHub after a handful of requests, with no hint that the cause was a typo in tokenEnv or a forgotten export in the shell.
The fallback branch (no tokenEnv set) is intentionally permissive because the caller did not request a specific env var, but the explicit-tokenEnv branch is asking for a specific token, so silently falling back to anonymous is surprising.
Expected behavior
When tokenEnv is explicitly supplied, an unset or empty value for that env var should produce an immediate, clear error from the GitHub constructor (or from searchIssues), rather than silently sending anonymous requests.
Minimal reproduction
import { GitHub } from 'loop-the-loop/prompt-generators/github/github';
delete process.env['CI_GITHUB_TOKEN'];
const github = new GitHub({ tokenEnv: 'CI_GITHUB_TOKEN' });
// No error. Subsequent searchIssues() calls go out without
// an Authorization header.
Suggested fix
In resolveToken, throw when the named env var is missing or empty:
if (options.tokenEnv !== undefined) {
const value = process.env[options.tokenEnv];
if (value === undefined || value === '') {
throw new Error(
`GitHub tokenEnv '${options.tokenEnv}' is not set; either set the env var or omit tokenEnv to fall back to GITHUB_TOKEN/GH_TOKEN`,
);
}
return value;
}
Note: the same pattern exists in src/prompt-generators/gitlab/gitlab.ts (resolveToken); a matching fix there would keep the two clients consistent.
- Lenguaje dominante
- TypeScript
- Estrellas
- 2
- Forks
- 1
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
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 joewalker/loop-the-loop
-
bug S4
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
joewalker/loop-the-loop#88 ·
-
Git exec(): child killed by a signal rejects with new Error('') and loses the signal informationAbiertobug S3
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
joewalker/loop-the-loop#84 ·
-
bug S3
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
joewalker/loop-the-loop#83 ·
-
bug S3
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
joewalker/loop-the-loop#82 ·
-
bug S4
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
joewalker/loop-the-loop#79 ·
Todos los issues de joewalker/loop-the-loop
Issues similares
-
[good first issue, hacktoberfest] 🏯 Hacktoberfest Task - Add new Japan Fact 898 (good-first-issue)Abiertocommunity first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Dificultad 1/5 Menos de una hora Aptitud para principiantes 86/100
lingdojo/kana-dojo#33145 · 1 comentario · 5 reacciones ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
code-yeongyu/senpi#4278 ·
Los mantenedores suelen responder en 1 día
-
[Bug] Activity | The activity list ignores taskIds and returns the activities of every taskPosiblemente ocupada @NdekoCode la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
ever-co/ever-gauzy#11469 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
griffinwork40/agent-afk#4408 ·
Los mantenedores suelen responder en 1 día