Firebase FunctionsをデプロイするときにHTTP Error: 400が出て少しハマった。
? functions: Finished running predeploy script.
i functions: ensuring necessary APIs are enabled...
? functions: all necessary APIs are enabled
i functions: preparing functions directory for uploading...
i functions: packaged functions (69.6 KB) for uploading
? functions: functions folder uploaded successfully
i functions: current functions in project: callCharge(us-central1), charge(us-central1), hello(us-central1)
i functions: uploading functions in project: sendReceptionMail(us-central1)
i functions: creating Node.js 8 function sendReceptionMail(us-central1)...
? functions: failed to create function sendReceptionMail
HTTP Error: 400, The request has errors
Functions deploy had errors. To continue deploying other features (such as database), run:
firebase deploy --except functions
Error: Functions did not deploy properly.400ということでプロジェクトやGoogleアカウントの認証周りを疑ったけど違った。
原因はdocumentを参照しなければいけないところでcollectionのパスを指定してしまっていたことだった。
エラーがちょっと不親切だけどCLIではなくコードの実行時のエラーだと分かっていれば次回はなんとかなりそう。
誤
exports.sendReceptionMail = functions
.firestore
.document('share_data/{userId}/corrections/')
.onCreate((snap, context) => {
//略正
exports.sendReceptionMail = functions
.firestore
.document('share_data/{userId}/corrections/{correctionId}')
.onCreate((snap, context) => {
//略- 作者: 小笠原みつき,西村公宏,柳佳音,志甫侑紀,池田友洋,木村涼平,?橋優介,大塚雅和,飯塚直,吉川竜太,末永恭正,久保田祐史,浜田真成,穴井宏幸,大島一将,桑原仁雄,牧大輔,池田拓司,はまちや2,竹原,WEB+DB PRESS編集部
- 出版社/メーカー: 技術評論社
- 発売日: 2018/06/23
- メディア: 単行本
- この商品を含むブログを見る
- 作者: 渡邊達明
- 出版社/メーカー: インプレスR&D
- 発売日: 2018/10/05
- メディア: Kindle版
- この商品を含むブログを見る