HTTPエラー処理

このページは機械翻訳により提供されています。翻訳内容と英語版に相違がある場合は、英語版が優先されます。

HTTPコネクターは、リクエストが失敗したときに問題を特定、管理、解決するのに役立つ充実したエラーデータを提示します。 HTTPステータス、標準化されたエラーメッセージ、およびヘッダーや本文などの構造化されたレスポンス詳細を表示します。 これらの詳細により、明確性が向上し、自動化がサポートされます。 この機能は現在、HTTPコネクターに適用されます。

エラーメッセージの表示方法

Send requestアクションが非2xxレスポンスを受信すると、コネクターはエラーを発生させます。

ジョブレポートのErrorタブには、以下が表示されます:

  • 構造化されたエラーメッセージ
  • HTTPレスポンスステータス
  • レスポンスヘッダー
  • レスポンス本文(該当する場合)

各値は専用フィールドに表示されます。 これらは、Monitorブロック、ログ、またはその他のエラー処理ロジックで使用できます。

MonitorおよびOn errorブロック用のHTTPコネクターエラーデータピル。MonitorおよびOn errorブロック用のHTTPコネクターエラーデータピル。

エラー構造

HTTPコネクターは、ジョブエラーに以下のフィールドを含めます:

フィールド説明
error_type_idエラータイプの安定した識別子。 例:err.http.response.client_error.not_found
error_typeHTTPステータスに基づく表示名。 例: 404 Not Found
error_idエラーインスタンスの一意の識別子。
error_message高レベルのメッセージ。 例: HTTP 500 error
http_response.code数値のHTTPステータスコード。 例: 404
http_response.status_textHTTPステータステキスト。 例:Not Found
http_response.headersHTTPレスポンスヘッダー。
http_response.body文字列としてのHTTPレスポンス本文。

エラーテキストの解析を避ける

自動化のためにerror_messageまたはerror_type値を解析することは避けてください。 これらのフィールドは表示値であり、変更される可能性があります。

信頼性の高いプログラムによるチェックには、error_type_idまたはhttp_response.codeを使用します。 error_type_idフィールドは、Workatoのエラー分類に準拠した安定した識別子を提供します。

HTTPエラーカテゴリー

HTTPコネクターは、非2xxレスポンスに対してエラーを発生させます。 これには、3xx HTTPリダイレクトエラー、4xxクライアントエラー、および5xxサーバーエラーが含まれます。

コネクターによって返されるHTTPエラーは、HTTPステータスコードクラスに基づく構造化されたerror_type_idパターンに従います。 HTTPエラータイプIDのこの構造化カタログは、現在HTTPコネクターでのみサポートされています。

HTTPステータスクラスerror_type_idプレフィックス説明
3xxerr.http.response.redirection.*301 Moved Permanently302 Found304 Not Modifiedなどのリダイレクトレスポンス。
4xxerr.http.response.client_error.*400 Bad Request401 Unauthorized403 Forbidden404 Not Foundなどのクライアント側エラー。
5xxerr.http.response.server_error.*500 Internal Server Error502 Bad Gateway503 Service Unavailableなどのサーバー側エラー。

MonitorまたはOn errorブロックでerror_type_idプレフィックスを使用して、関連するHTTP失敗をグループ化できます。

Retry succeeds列は、レシピがパラメーターを変更せずに同じリクエストを再試行した場合に成功する可能性があるかどうかを示します。 これは、このセクションの以下の表に適用されます。

HTTPリダイレクトエラータイプID

HTTPコネクターは、HTTP 3xxレスポンスに対して以下のerror_type_id値を返します:

HTTPステータスerror_type_id再試行成功
300 Multiple Choiceserr.http.response.redirection.multiple_choicesいいえ
301 Moved Permanentlyerr.http.response.redirection.moved_permanentlyいいえ
302 Founderr.http.response.redirection.foundいいえ
303 See Othererr.http.response.redirection.see_otherいいえ
304 Not Modifiederr.http.response.redirection.not_modifiedいいえ
305 Use Proxyerr.http.response.redirection.use_proxyいいえ
306 Unusederr.http.response.redirection.unusedいいえ
307 Temporary Redirecterr.http.response.redirection.temporary_redirectいいえ
308 Permanent Redirecterr.http.response.redirection.permanent_redirectいいえ

HTTPクライアントエラータイプID

HTTPコネクターは、HTTP 4xxレスポンスに対して以下のerror_type_id値を返します:

HTTPステータスerror_type_id再試行成功
400 Bad Requesterr.http.response.client_error.bad_requestいいえ
401 Unauthorizederr.http.response.client_error.unauthorizedいいえ
402 Payment Requirederr.http.response.client_error.payment_requiredいいえ
403 Forbiddenerr.http.response.client_error.forbiddenいいえ
404 Not Founderr.http.response.client_error.not_foundいいえ
405 Method Not Allowederr.http.response.client_error.method_not_allowedいいえ
406 Not Acceptableerr.http.response.client_error.not_acceptableいいえ
407 Proxy Authentication Requirederr.http.response.client_error.proxy_authentication_requiredいいえ
408 Request Timeouterr.http.response.client_error.request_timeoutはい
409 Conflicterr.http.response.client_error.conflictいいえ
410 Goneerr.http.response.client_error.goneいいえ
411 Length Requirederr.http.response.client_error.length_requiredいいえ
412 Precondition Failederr.http.response.client_error.precondition_failedいいえ
413 Content Too Largeerr.http.response.client_error.content_too_largeいいえ
414 URI Too Longerr.http.response.client_error.uri_too_longいいえ
415 Unsupported Media Typeerr.http.response.client_error.unsupported_media_typeいいえ
416 Range Not Satisfiableerr.http.response.client_error.range_not_satisfiableいいえ
417 Expectation Failederr.http.response.client_error.expectation_failedいいえ
418 I'm a teapoterr.http.response.client_error.i_m_a_teapotいいえ
421 Misdirected Requesterr.http.response.client_error.misdirected_requestいいえ
422 Unprocessable Contenterr.http.response.client_error.unprocessable_contentいいえ
423 Lockederr.http.response.client_error.lockedはい
424 Failed Dependencyerr.http.response.client_error.failed_dependencyいいえ
425 Too Earlyerr.http.response.client_error.too_earlyはい
426 Upgrade Requirederr.http.response.client_error.upgrade_requiredいいえ
428 Precondition Requirederr.http.response.client_error.precondition_requiredいいえ
429 Too Many Requestserr.http.response.client_error.too_many_requestsはい
431 Request Header Fields Too Largeerr.http.response.client_error.request_header_fields_too_largeいいえ
451 Unavailable For Legal Reasonserr.http.response.client_error.unavailable_for_legal_reasonsいいえ

HTTPサーバーエラータイプID

HTTPコネクターは、HTTP 5xxレスポンスに対して以下のerror_type_id値を返します:

HTTPステータスerror_type_id再試行成功
500 Internal Server Errorerr.http.response.server_error.internal_server_errorはい
501 Not Implementederr.http.response.server_error.not_implementedいいえ
502 Bad Gatewayerr.http.response.server_error.bad_gatewayはい
503 Service Unavailableerr.http.response.server_error.service_unavailableはい
504 Gateway Timeouterr.http.response.server_error.gateway_timeoutはい
505 HTTP Version Not Supportederr.http.response.server_error.http_version_not_supportedいいえ
506 Variant Also Negotiateserr.http.response.server_error.variant_also_negotiatesいいえ
507 Insufficient Storageerr.http.response.server_error.insufficient_storageはい
508 Loop Detectederr.http.response.server_error.loop_detectedいいえ
510 Not Extendederr.http.response.server_error.not_extendedいいえ
511 Network Authentication Requirederr.http.response.server_error.network_authentication_requiredいいえ

エラーとして扱われる成功HTTPレスポンスコード

HTTPコネクターは、下位互換性のために、特定の成功HTTPレスポンスをエラーとして扱う場合があります。

これらのレスポンスは成功HTTPステータスコードを使用しますが、HTTPコネクターではエラーとして表示される場合があります。

HTTPステータスerror_type_id
208 Already Reportederr.http.response.successful.already_reported
226 IM Usederr.http.response.successful.im_used

サポートされていないRFC HTTPレスポンスコード

HTTPコネクターは、サポートされているRFC定義のレスポンスコードにマッピングされないHTTPステータスコードを受信すると、フォールバックerror_type_id値を返す場合があります。 これらの識別子は、サポートされていない、または非標準のHTTPレスポンスコードを表します:

カテゴリerror_type_id
情報(1xx)err.http.response.unsupported_rfc.informational
成功(2xx)err.http.response.unsupported_rfc.successful
リダイレクト(3xx)err.http.response.unsupported_rfc.redirection
クライアントエラー(4xx)err.http.response.unsupported_rfc.client_error
サーバーエラー(5xx)err.http.response.unsupported_rfc.server_error
一般err.http.response.unsupported_rfc.general

構造化されたHTTPエラー出力

HTTPコネクターは、デバッグ、フィルタリング、自動化に使用できる構造化されたエラーオブジェクトを返します。 このオブジェクトには、HTTPステータスコード、レスポンス本文、ヘッダー、機械可読なエラータイプIDなどのフィールドが含まれます。 例:

json
{
  "error_type_id": "err.http.response.client_error.not_found",
  "error_type": "Not Found",
  "error_id": "ad6a...b3c",
  "error_message": "HTTP 404 error",
  "http_response": {
    "code": 404,
    "status_text": "Not Found",
    "body": "{\"error\": \"Resource not found\"}",
    "headers": {
      "Content-Type": "application/json"
    }
  }
}

この構造化されたエラーデータには、以下からアクセスできます:

  • ジョブレポート
  • Monitorブロック(エラーデータピル)
  • On errorブロック(エラーデータピル)

Workatoでは、自動化にerror_type_idを使用することを推奨しています。 このフィールドは安定しており、信頼性の高いプログラムによるチェックをサポートします。

エラー処理のベストプラクティス

信頼性の高いレシピを構築するには、MonitorまたはOn errorブロックでerror_type_idおよびhttp_responseフィールドを使用します:

  • error_type_idを使用して特定のエラーをキャッチして処理
  • HTTPステータスコードまたはレスポンスヘッダーに基づいてリクエストを再試行
  • 構造化されたエラーデータをログまたはアラートシステムに送信

これらのフィールドにより、文字列解析や壊れやすいパターンマッチングが不要になります。

Last updated: