CodeGenieApp / CodeGenieApp/serverless-express

`headers` is always replaced by `multiValueHeaders` with ALB events response

Abierto
#464 0 comentarios 1 reacción 0 asignados Ver en GitHub
Lenguaje dominante
JavaScript
Estrellas
5.3k
Forks
676
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

**Context:** upgrading from 3.3.8 to 4.3.11.

`headers` is always replaced by `multiValueHeaders` : https://github.com/vendia/serverless-express/blob/6adac653fe1daf1dd44ff6aa17dbf08f07662173/src/event-sources/aws/alb.js#L40-L54

But according to https://docs.aws.amazon.com/elasticloadbalancing/latest/application/lambda-functions.html#multi-value-headers, it should only happen when the multi-value headers feature is enabled on the target group.

I tried to put back `headers` with a custom `getResponse` mapper :
```javascript
const customResponse = ({ statusCode, body, headers, isBase64Encoded }) => {
return {
statusCode,
body,
headers,
isBase64Encoded,
};
};
```

But then I get :
```javascript
"errorMessage": "eventSource.getRequest is not a function",
"stack": [
"TypeError: eventSource.getRequest is not a function",
" at forwardRequestToNodeServer (/var/task/server.js:41241:37)",
" at /var/task/server.js:40578:9",
" at new Promise ()",
" at proxy (/var/task/server.js:40565:12)",
" at Runtime.handler (/var/task/server.js:40602:12)",
" at Runtime.handleOnce (/var/runtime/Runtime.js:66:25)"
]
```

So it seems that if `getResponse` is set, `getRequest`has to be set as well. This is not ideal as the request mapper is not exported and cannot be used directly.

I don't know what could be the best solution to address this, ​but at least allowing to set only `getResponse` mapper should allow us to fix the initial issue.

Sister issue but for API Gateway : https://github.com/vendia/serverless-express/issues/437

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Comienza con src/event-sources/aws/alb.js en el código de mapeo de respuestas enlazado y lee la documentación de AWS ALB sobre los encabezados de valores múltiples. Traza cómo se seleccionan getResponse y getRequest y, después, verifica que los encabezados de un solo valor se conserven cuando la funcionalidad está deshabilitada y que se pueda usar un mapper getResponse personalizado por sí solo.

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

Evaluación

Stack tecnológico
aws, express, javascript, node.js
Área
api, backend, cloud
Tipo de issue
Error
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.