Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

util/config: assertOptionalStringArray '// istanbul ignore else' hides untested 'array contains non-strings' branch

Abierto Apto para principiantes
#68 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
72/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Tranquilo
Stack tecnológico
typescript
Área
testing-qa

Línea de trabajo

Comienza en src/prompt-generators/util/config.ts, en assertOptionalStringArray, y revisa después los casos relevantes en load-cli-config.test.ts. Ejecuta las pruebas enfocadas y la cobertura, añade un caso para un array que contenga un elemento que no sea una cadena y verifica que el validador y el informe de cobertura ejecuten esa rama sin una directiva ignore injustificada.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

bug S4

Observed behavior

assertOptionalStringArray in src/prompt-generators/util/config.ts (lines 76-90) has an // istanbul ignore else directive immediately above its validation check:

export function assertOptionalStringArray(
  value: Record<string, unknown>,
  key: string,
  field: string,
): void {
  if (!(key in value)) {
    return;
  }

  const array = value[key];
  // istanbul ignore else
  if (!Array.isArray(array) || array.some(item => typeof item !== 'string')) {
    throw new Error(`${field} must be an array of strings`);
  }
}

git blame traces the directive to commit 8f4d7d6 ("Push coverage to 100% using ignores"). The condition is a two-clause OR:

  1. !Array.isArray(array) - covered by tests that pass a plain string for an array field (e.g. load-cli-config.test.ts:503, :720 pass components: 'DOM: Workers' and labels: 'bug').
  2. array.some(item => typeof item !== 'string') - I cannot find a single test in the repo that passes an array containing a non-string item to a field validated by assertOptionalStringArray. Searching for tests using bugStatus, keywords, components, bugFields, bugSeverity, labels, and excludePatterns only turns up valid string arrays and "not even an array" failure cases.

The // istanbul ignore else is on the if statement, so strictly it suppresses the implicit "else" (no-throw) branch, not the OR's branch coverage. But it sits exactly where a branch is uncovered. Combined with the commit message, this strongly suggests the directive is silencing a real coverage gap: the array.some(...) arm of the OR has no test.

The runtime consequence is small but real: a regression that broke the per-item string check (for example, changing typeof item !== 'string' to typeof item === 'string', or accidentally removing the .some call) would not be caught by any existing test, and coverage would still report 100%.

Expected behavior

Either:

  • Remove the // istanbul ignore else directive and add a test that calls assertOptionalStringArray (or one of its callers, like normalizeBugzillaTaskConfig with bugStatus: ['OPEN', 42]) with an array containing a non-string item, so both arms of the OR are covered by an actual assertion, or
  • If the success path is the one that needs the suppression (because v8 is flagging it), explicitly justify that in a comment so future readers do not assume the directive is masking a different gap.

Minimal reproduction

import { assertOptionalStringArray } from './prompt-generators/util/config.js';

// Tests in the repo cover:
assertOptionalStringArray({ foo: 'bar' }, 'foo', 'test.foo'); // throws (first OR arm)
assertOptionalStringArray({ foo: ['a', 'b'] }, 'foo', 'test.foo'); // does not throw (else of if)

// Not covered anywhere:
assertOptionalStringArray({ foo: ['a', 42] }, 'foo', 'test.foo'); // throws (second OR arm)

Suggested fix

Remove the // istanbul ignore else line and add a unit test (or extend load-cli-config.test.ts) that exercises an array with at least one non-string element, e.g.:

it('should reject Bugzilla bugStatus arrays containing non-strings', async () => {
  await expect(
    normalizeCliConfig(
      {
        name: 'test',
        agent: 'claude-sdk',
        promptGenerator: [
          'bugzilla',
          {
            search: { bugStatus: ['OPEN', 42] },
            promptTemplate: 'Review {{id}}',
          } as unknown as BugzillaTask,
        ],
      },
      join(configDir, 'config.json'),
    ),
  ).rejects.toThrow('bugzilla.search.bugStatus must be an array of strings');
});

Severity

S4 - cleanup with low behavioral risk. The validator works correctly today; the issue is that a future regression in the per-item type check would slip past both tests and the 100% coverage gate.

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

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de joewalker/loop-the-loop

Todos los issues de joewalker/loop-the-loop

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.