Skip to content

[JV2-158] Normalize request header keys to lowercase#9

Merged
jormaechea merged 2 commits into
masterfrom
fix/JV2-158-normalize-header-case
Jun 29, 2026
Merged

[JV2-158] Normalize request header keys to lowercase#9
jormaechea merged 2 commits into
masterfrom
fix/JV2-158-normalize-header-case

Conversation

@jormaechea

@jormaechea jormaechea commented Jun 26, 2026

Copy link
Copy Markdown
Member

Qué

Normaliza las keys de los headers del request a lowercase en el Dispatcher, antes de propagarlas a this.api.headers. Aplica a todas las APIs (list, get, save, delete, custom).

Por qué

Los nombres de header HTTP son case-insensitive (RFC 7230). Sobre HTTP/2 se fuerzan a lowercase, pero sobre HTTP/1 un consumidor puede mandarlos en cualquier casing (ej. x-janis-Page). Una API que lee el header en lowercase exacto no lo encuentra y cae al default.

Caso real (PROD y QA): views manda x-janis-Page en camelCase desde un componente checklist. Sobre HTTP/1 el back lo ignora, aplica page=1, devuelve siempre los primeros 100 registros y entra en loop infinito de paginación. Internamente no se veía porque usamos HTTP/2.

Cambios

  • lib/utils.js: nuevo util lowerCaseKeys() (con guarda para no-objetos).
  • lib/dispatcher.js: this.headers = lowerCaseKeys(request.headers || {}).
  • tests/: test e2e en dispatcher + unit tests del util. Coverage 100%.
  • README.md: nota en el getter headers sobre la normalización.
  • CHANGELOG.md: entrada en [Unreleased].

Validación

  • 53 passing, lint OK, coverage 100%.
  • Funcional pendiente: validar en QA con el usuario que la vista del perfil termina de cargar.

Ref: https://janiscommerce.atlassian.net/browse/JV2-158

🤖 Generated with Claude Code

HTTP header names are case-insensitive (RFC 7230). Over HTTP/2 they are
forced to lowercase, but over HTTP/1 a consumer may send them in any case
(e.g. 'x-janis-Page'), causing APIs that read headers in lowercase to miss
them and fall back to defaults (e.g. an infinite pagination loop in api-list).

Normalize header keys to lowercase in the dispatcher so every API reads them
consistently regardless of the casing received.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@mdanelutti mdanelutti left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@jormaechea jormaechea merged commit 6426a69 into master Jun 29, 2026
3 checks passed
@jormaechea jormaechea deleted the fix/JV2-158-normalize-header-case branch June 29, 2026 19:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants