fix(admin): batch param is unclamped and batch=0 spins 50 no-op batches in all=true mode
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
- 76/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Stack tecnológico
- typescript
Línea de trabajo
Empieza en apps/web/app/routes/api.admin.recompute.ts, en parseIntSafe, la asignación de batchSize y el bucle all=true; compara la validación con el comportamiento descrito en recompute-all-skills.ts:177. Usa la reproducción proporcionada con curl de ADMIN_SECRET y los bindings D1 y KV requeridos; después verifica que los valores de batch estén acotados y que batch=0 ya no produzca 50 batches sin operación.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Summary
The batch query parameter is neither clamped nor range-checked on POST /api/admin/recompute. parseIntSafe rejects only NaN and negative values, so batch=0 is accepted and there is no upper bound either. With all=true, batch=0 makes one request burn all 50 permitted batch iterations while processing nothing.
Current behavior
apps/web/app/routes/api.admin.recompute.ts:28-32— the only validation, which lets0through and caps nothing:function parseIntSafe(value: string | null, fallback: number): number { if (value == null) return fallback; const n = parseInt(value, 10); return Number.isNaN(n) || n < 0 ? fallback : n; }apps/web/app/routes/api.admin.recompute.ts:58— that value becomesbatchSizeand reaches.limit(batchSize)in the query builder, sobatch=0becomesLIMIT 0.apps/web/app/lib/leaderboard/recompute-all-skills.ts:177— with an empty batch the completion test is0 < 0, which is false:
The batch is reported as incomplete, andconst isComplete = batch.length < batchSize;nextOffsetis set tooffsetunchanged, so theall=trueloop atapps/web/app/routes/api.admin.recompute.ts:81keeps calling with the same offset untilMAX_BATCHES_PER_REQUEST(50) is reached, then returns "Paused after 50 batches" with nothing processed.- There is also no upper bound:
batch=100000is accepted and would defeat the guard added at line 21 to keep the Worker under its CPU limit.
Expected behavior
Clamp the value to a sane range, as the review recommended, and reject nonsense input explicitly:
const batchSize = Math.min(Math.max(parseIntSafe(batch, 100), 1), 500);
Reproduction
- Set
batchto0and select all-at-once mode:ADMIN_SECRET=... curl -sS -X POST "https://skillx.sh/api/admin/recompute?all=true&batch=0" - The response reports
batches: 50,totalProcessed: 0, and the "Paused after 50 batches" message, whileGET /api/admin/recomputeshows the checkpoint unchanged.
Conditions: requires ADMIN_SECRET plus the D1 and KV bindings; admin-only endpoint. Behavior read from main at 9d0f9e9; the exact request was not executed against production.
Flow
flowchart LR
A["batch=0"] --> B[parseIntSafe returns 0]
B --> C["LIMIT 0 -> empty batch"]
C --> D{{"isComplete = 0 < 0 = false"}}
D -->|nextOffset unchanged| E[all=true loop retries same offset]
E --> F[50 no-op batches, then Paused]
Evidence
- Affected code:
apps/web/app/routes/api.admin.recompute.ts:28,apps/web/app/routes/api.admin.recompute.ts:58,apps/web/app/routes/api.admin.recompute.ts:81,apps/web/app/lib/leaderboard/recompute-all-skills.ts:177 - Introduced by:
88a5bff, shipped onmainvia9d0f9e9(PR #9) - Related:
plans/reports/code-reviewer-260306-1531-admin-recompute-endpoint.md, section "8. Input validation forbatchandoffsetparams"
Open questions
- Upper bound: 500 as suggested in the review, or align it with the existing default of 100?
- Should
batch=0return HTTP 400 instead of being silently clamped to 1?
Notes
offsethas the same missing upper clamp, but an out-of-range offset only yields an empty batch and a correct completion, so it is far less harmful thanbatch=0.MAX_BATCHES_PER_REQUESTat line 21 already handles the Worker-timeout risk from the review; the missing piece is bounding the work each iteration can request.
- Lenguaje dominante
- TypeScript
- Estrellas
- 189
- Forks
- 40
- Merge medio
- 6 h 54 min
- PR fusionados (30 d)
- 24
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 nextlevelbuilder/skillx
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
nextlevelbuilder/skillx#49 ·
Los mantenedores suelen responder en 1 día
-
refactor
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
nextlevelbuilder/skillx#27 ·
Los mantenedores suelen responder en 1 día
-
Harden personal kit proposal scanning before enabling the API flagPosiblemente ocupada @mrgoonie la tomó hoy. Abierto
nextlevelbuilder/skillx#86 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 18/100
nextlevelbuilder/skillx#84 ·
Los mantenedores suelen responder en 1 día
-
enhancement
Dificultad 5/5 Más de una semana Aptitud para principiantes 12/100
nextlevelbuilder/skillx#81 ·
Los mantenedores suelen responder en 1 día
Todos los issues de nextlevelbuilder/skillx
Issues similares
-
fix(frontend): correct VITE_IS_DEVELPOMENT typo in shared/app.ts and align dev environment flagsAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
vicharanashala/ajrasakha#1439 ·
Los mantenedores suelen responder en 1 día
-
Add: TV5Monde AsieAbiertoapproved check:passed streams:add
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
codex-team/editor.js#3037 ·
-
complexity: trivial good first issue impact: low
Dificultad 1/5 Menos de una hora Aptitud para principiantes 78/100
ueberdosis/tiptap#8522 ·
Los mantenedores suelen responder en 1 día
-
Bump anybuf version to ^1.0.0Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
wormhole-foundation/wormhole#5062 ·
Los mantenedores suelen responder en 1 día