やりたかった事(ハマった事)
以下のように Golang で Step Functions の Activity Task で実行される処理が失敗した際に出力される結果を TaskFailure として送信したかった。
...
params := &sfn.SendTaskFailureInput{
Error: aws.String(message),
TaskToken: activity.TaskToken,
}
_, err := sfnSession.SendTaskFailure(params)
if err != nil {
log.Printf(err.Error())
os.Exit(1)
}
...
ところが、出力がある一定の長さを超えると以下のようなエラーとなってしまった。
2017/09/04 22:29:32 ValidationException: 1 validation error detected: Value 'エラーメッセージ...エラーメッセージ...エラーメッセージ...エラーメッセージ' at 'error' failed to satisfy constraint: Member must have length less than or equal to 256
どうやら error キーの値は 256 文字以内という制限があるようだ。
解っていなかった事
256 文字以内という制限が有るのは解ったが、どこにそれが定義されているのかとドキュメントを探していたら、素の API ドキュメントに記述があった。
リクエストパラメータをドキュメントより転載。
| パラメータ | 詳細 | Type | Length Constraints | Required |
|---|---|---|---|---|
| cause | A more detailed explanation of the cause of the failure. | String | Minimum length of 0. Maximum length of 32768. | No |
| error | An arbitrary error code that identifies the cause of the failure. | String | Minimum length of 0. Maximum length of 256. | No |
| taskToken | The token that represents this task. Task tokens are generated by the service when the tasks are assigned to a worker (see GetActivityTask::taskToken). | String | Minimum length of 1. Maximum length of 1024. | Yes |
なるほど。
本来は error にはエラーの概要を記載して cause にエラーの原因となるメッセージを書くべきんだんと思うけど、何も考えずに error に突っ込んでしまっていた自分のこれまた知ったかぶりだった。
その他、Step Functions 自体の制限は以下に記載されている。