CodeGenieApp / CodeGenieApp/serverless-express

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

オープン
#464 コメント 0 件 リアクション 1 件 担当者 0 名 GitHub で見る
主要言語
JavaScript
スター
5.3k
フォーク
676
PR マージ指標
30日以内にマージされた PR はありません

説明

**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

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

src/event-sources/aws/alb.js のリンク先のレスポンスマッピングコードから始め、AWS ALB のマルチバリューヘッダーに関するドキュメントを読んでください。getResponse と getRequest がどのように選択されるかを追跡し、その後、機能が無効な場合に単一値ヘッダーが保持されることと、カスタムの getResponse mapper を単独で使用できることを確認してください。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
aws, express, javascript, node.js
領域
api, backend, cloud
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。