[JV2-158] Normalize request header keys to lowercase#9
Open
jormaechea wants to merge 1 commit into
Open
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Qué
Normaliza las keys de los headers del request a lowercase en el
Dispatcher, antes de propagarlas athis.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-Pageen camelCase desde un componente checklist. Sobre HTTP/1 el back lo ignora, aplicapage=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 utillowerCaseKeys()(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 getterheaderssobre la normalización.CHANGELOG.md: entrada en[Unreleased].Validación
Ref: https://janiscommerce.atlassian.net/browse/JV2-158
🤖 Generated with Claude Code