JSON Threat Protection 執行階段錯誤疑難排解

您正在查看 Apigee Edge 說明文件。
查看 Apigee X 說明文件
資訊

ExecutionFailed

錯誤代碼

steps.jsonthreatprotection.ExecutionFailed

錯誤回應主體

{
    "fault": {
        "faultstring": "JSONThreatProtection[policy_name]:
          Execution failed. reason: JSONThreatProtection[policy_name]: error_description
          at line line_num",
        "detail": {
            "errorcode": "steps.jsonthreatprotection.ExecutionFailed"
        }
    }
}

錯誤類型和可能原因

JSONThreatProtection 政策可能會擲回許多不同類型的 ExecutionFailed 錯誤。下表列出各種錯誤類型和可能原因:

錯誤類型 原因
超過物件項目名稱長度 超過物件項目名稱允許的字串長度上限。
超過物件項目數量 超過物件允許的項目數量上限。
超過陣列元素數量 超過陣列中允許的元素數量上限。
超過容器深度 超過允許的巢狀深度上限。
超過字串值長度 超過字串值允許的長度上限。
JSON 物件無效 輸入的 JSON 酬載無效。

超過物件項目名稱長度

錯誤回應主體

{
    "fault": {
        "faultstring": "JSONThreatProtection[policy_name]:
          Execution failed. reason: JSONThreatProtection[policy_name]:
          Exceeded object entry name length at line line_num",
        "detail": {
            "errorcode": "steps.jsonthreatprotection.ExecutionFailed"
        }
    }
}

錯誤回應主體範例

{
    "fault": {
        "faultstring": "JSONThreatProtection[JSON-Threat-Protection-1]:
          Execution failed. reason: JSONThreatProtection[JSON-Threat-Protection-1]:
          Exceeded object entry name length at line 2",
        "detail": {
            "errorcode": "steps.jsonthreatprotection.ExecutionFailed"
        }
    }
}

原因

如果 <Source> 元素指定的輸入訊息酬載包含 JSON 物件,其屬性名稱超出 <ObjectEntryNameLength> 元素中指定的長度上限,就會發生這個錯誤。

舉例來說,如果政策中的 <ObjectEntryNameLength> 元素指定為 5,但輸入訊息酬載的 JSON 屬性名稱超過 5 個字元,則系統會擲回這個錯誤。

診斷

  1. 檢查錯誤訊息,找出 JSONThreatProtection 政策名稱和出現長項目名稱的行號。例如,在下列錯誤訊息中,JSONThreatProtection 政策名稱為 JSON-Threat-Protection-1,酬載中的行號為 2。

    JSONThreatProtection[JSON-Threat-Protection-1]: Execution failed. reason:
    JSONThreatProtection[JSON-Threat-Protection-1]: Exceeded object entry name
    length at line 2
    
  2. 檢查您在步驟 1 中指定的政策,並記下 <ObjectEntryNameLength> 元素中指定的值。

    例如,在下列 JSONThreatProtection 政策中,<ObjectEntryNameLength> 設為 5

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <JSONThreatProtection async="false" continueOnError="false" enabled="true" name="JSON-Threat-Protection-1">
        <DisplayName>JSON Threat Protection-1</DisplayName>
        <Properties/>
        <ArrayElementCount>3</ArrayElementCount>
        <ContainerDepth>12</ContainerDepth>
        <ObjectEntryCount>5</ObjectEntryCount>
        <ObjectEntryNameLength>5</ObjectEntryNameLength>
        <Source>request</Source>
        <StringValueLength>50</StringValueLength>
    </JSONThreatProtection>
    
  3. 檢查輸入酬載的特定行號 (如步驟 1 所示),並檢查物件名稱的長度是否大於 <ObjectEntryNameLength> 元素中指定的值 (如步驟 2 所示)。如果物件名稱的長度超過這個數字,就會導致錯誤。

    以下是輸入酬載的範例:

    {
       "number" : 500,
       "string" : "text"
    }
    

    上方顯示的 JSON 酬載在第 2 行含有名為 number 的屬性,該屬性有 6 個字元 (名稱長度為 6)。由於物件名稱的長度大於 5 (<ObjectEntryNameLength> 元素指定的值),您會收到以下錯誤:

    JSONThreatProtection[JSON-Threat-Protection-1]: Execution failed. reason:
    JSONThreatProtection[JSON-Threat-Protection-1]: Exceeded object entry name
    length at line 2
    

解析度

如果 JSONThreatProtection 政策的作用是避免酬載中的物件項目名稱超過定義值,就會傳回錯誤訊息。在這種情況下,您不需要採取其他動作。

不過,如果您確定可以在酬載中指定較長的物件項目名稱,且不會產生任何結果,請根據需求將 <ObjectEntryNameLength> 修改為適當的值。

例如,如果您認為自己可以使用最長 10 個字元的物件名稱,請按照下列步驟修改 JSONThreatProtection 政策:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<JSONThreatProtection async="false" continueOnError="false" enabled="true" name="JSON-Threat-Protection-1">
    <DisplayName>JSON Threat Protection-1</DisplayName>
    <Properties/>
    <ArrayElementCount>3</ArrayElementCount>
    <ContainerDepth>12</ContainerDepth>
    <ObjectEntryCount>5</ObjectEntryCount>
    <ObjectEntryNameLength>10</ObjectEntryNameLength>
    <Source>request</Source>
    <StringValueLength>50</StringValueLength>
</JSONThreatProtection>

已超出物件項目數量

錯誤回應主體

{
    "fault": {
        "faultstring": "JSONThreatProtection[policy_name]:
          Execution failed. reason: JSONThreatProtection[policy_name]:
          Exceeded object entry count at line line_num",
        "detail": {
            "errorcode": "steps.jsonthreatprotection.ExecutionFailed"
        }
    }
}

錯誤回應主體範例

{
    "fault": {
        "faultstring": "JSONThreatProtection[JSON-Threat-Protection-1]:
          Execution failed. reason: JSONThreatProtection[JSON-Threat-Protection-1]:
          Exceeded object entry count at line 7",
        "detail": {
            "errorcode": "steps.jsonthreatprotection.ExecutionFailed"
        }
    }
}

原因

如果 <Source> 元素指定的輸入訊息酬載包含 JSON 物件,該物件包含的項目 (屬性) 超過政策 <ObjectEntryCount> 元素中指定的值,就會發生這個錯誤。

舉例來說,如果 <ObjectEntryCount> 元素為 5,但輸入的 JSON 酬載超過 5 個項目,系統就會擲回這個錯誤。

診斷

  1. 檢查錯誤訊息,找出 JSONThreatProtection 政策名稱和超出項目數量的行號。例如,在下列錯誤訊息中,政策名稱為 JSON-Threat-Protection-1,酬載中的行號為 7

    JSONThreatProtection[JSON-Threat-Protection-1]: Execution failed. reason:
    JSONThreatProtection[JSON-Threat-Protection-1]: Exceeded object entry count
    at line 7
    
  2. 記下政策 <ObjectEntryCount> 元素中指定的值 (於步驟 1 識別)。

    在以下政策範例中,<ObjectEntryCount> 設為 5

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <JSONThreatProtection async="false" continueOnError="false" enabled="true" name="JSON-Threat-Protection-1">
        <DisplayName>JSON Threat Protection-1</DisplayName>
        <Properties/>
        <ArrayElementCount>3</ArrayElementCount>
        <ContainerDepth>12</ContainerDepth>
        <ObjectEntryCount>5</ObjectEntryCount>
        <ObjectEntryNameLength>6</ObjectEntryNameLength>
        <Source>request</Source>
        <StringValueLength>50</StringValueLength>
    </JSONThreatProtection>
    
  3. 檢查輸入酬載的特定行號 (如步驟 1 所示),並檢查酬載中的實體數量是否大於 <ObjectEntryCount> 元素中指定的值 (於步驟 2 識別)。如果物件數量超過物件項目數量,這就是發生錯誤的原因。

    以下是輸入酬載的範例:

    {
    "name" : "John",
    "id" : 234687,
    "age" : 31,
    "city" : "New York",
    "country" : "USA",
    "company" : "Google"
    }
    

    在上方顯示的 JSON 酬載中,第 6 個項目發生在第 7 行 (公司)。由於輸入 JSON 酬載中的物件項目數量大於 5 (為 <ObjectEntryCount> 元素指定的值),因此您會收到以下錯誤:

    JSONThreatProtection[JSON-Threat-Protection-1]: Execution failed. reason:
    JSONThreatProtection[JSON-Threat-Protection-1]: Exceeded object entry count at
    line 7
    

解析度

如果 JSONThreatProtection 政策的用意是避免含有多個物件項目超過特定門檻的酬載,則預期會顯示錯誤訊息。在這種情況下,你無須採取其他行動。

不過,如果您確定在酬載中可納入更多物件項目,且不會產生任何結果,請根據您的需求將 <ObjectEntryCount> 修改為適當的值。

例如,如果您認為您最多可允許 10 個物件項目,請依照下列方式修改 JSONThreatProtection 政策:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<JSONThreatProtection async="false" continueOnError="false" enabled="true" name="JSON-Threat-Protection-1">
    <DisplayName>JSON Threat Protection-1</DisplayName>
    <Properties/>
    <ArrayElementCount>3</ArrayElementCount>
    <ContainerDepth>12</ContainerDepth>
    <ObjectEntryCount>10</ObjectEntryCount>
    <ObjectEntryNameLength>6</ObjectEntryNameLength>
    <Source>request</Source>
    <StringValueLength>50</StringValueLength>
</JSONThreatProtection>

超過陣列元素數量

錯誤回應主體

{
    "fault": {
        "faultstring": "JSONThreatProtection[policy_name]:
          Execution failed. reason: JSONThreatProtection[policy_name]:
          Exceeded array element count at line line-num",
        "detail": {
            "errorcode": "steps.jsonthreatprotection.ExecutionFailed"
        }
    }
}

錯誤回應主體範例

{
    "fault": {
        "faultstring": "JSONThreatProtection[JSON-Threat-Protection-1]:
          Execution failed. reason: JSONThreatProtection[JSON-Threat-Protection-1]:
          Exceeded array element count at line 3",
        "detail": {
            "errorcode": "steps.jsonthreatprotection.ExecutionFailed"
        }
    }
}

原因

如果 <Source> 元素指定的輸入訊息酬載包含 JSON 陣列,其中元素數量超過政策 <ArrayElementCount> 元素中指定的數量,就會發生這個錯誤。

舉例來說,如果 <ArrayElementCount> 元素指定為 3,但輸入酬載的 JSON 陣列含有超過 3 個元素,就會擲回這個錯誤。

診斷

  1. 檢查錯誤訊息,找出政策名稱和超過陣列長度的行號。例如,在下列錯誤訊息中,政策名稱為 JSON-Threat-Protection-1,酬載中的行號為 3

    JSONThreatProtection[JSON-Threat-Protection-1]: Execution failed. reason:
    JSONThreatProtection[JSON-Threat-Protection-1]: Exceeded array element count at line 3
    
  2. 記下政策的 <ArrayElementCount> 元素指定的值 (於步驟 1 識別)。

    在以下 JSONThreatProtection 政策範例中,<ArrayElementCount> 設為 3

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <JSONThreatProtection async="false" continueOnError="false" enabled="true" name="JSON-Threat-Protection-1">
        <DisplayName>JSON Threat Protection-1</DisplayName>
        <Properties/>
        <ArrayElementCount>3</ArrayElementCount>
        <ContainerDepth>12</ContainerDepth>
        <ObjectEntryCount>5</ObjectEntryCount>
        <ObjectEntryNameLength>6</ObjectEntryNameLength>
        <Source>request</Source>
        <StringValueLength>50</StringValueLength>
    </JSONThreatProtection>
    
  3. 檢查輸入酬載的特定行號 (已在步驟 1 中找出),並檢查指定的陣列數量是否高於 <ArrayElementCount> 元素中指定的陣列數量 (請見步驟 2)。如果陣列元素數量超過計數,表示發生錯誤。

    以下是輸入酬載的範例:

    {
     "name":"Ford",
     "models":[
        "Mustang",
        "Endeavour",
        "Fiesta",
        "EcoSport",
        "Focus"
     ]
    }
    

    上方顯示的 JSON 酬載在第 3 行名為 models 的陣列中有 5 個元素。由於陣列元素數量大於 3 (<ArrayElementCount> 元素指定的值),因此您會收到以下錯誤:

    JSONThreatProtection[JSON-Threat-Protection-1]: Execution failed. reason:
    JSONThreatProtection[JSON-Threat-Protection-1]: Exceeded array element count
    at line 3
    

解析度

如果 JSONThreatProtection 政策是要防範設有特定陣列數量門檻的酬載,則預期會出現錯誤訊息。在這種情況下,您不需要採取其他動作。

但是,如果您確定可以使用陣列中的更多元素,請根據您的需求將 <ArrayElementCount> 修改為適當的值。

例如,如果您認為自己可以允許最多 5 個陣列元素,請按照下列方式修改政策:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<JSONThreatProtection async="false" continueOnError="false" enabled="true" name="JSON-Threat-Protection-1">
    <DisplayName>JSON Threat Protection-1</DisplayName>
    <Properties/>
    <ArrayElementCount>5</ArrayElementCount>
    <ContainerDepth>12</ContainerDepth>
    <ObjectEntryCount>5</ObjectEntryCount>
    <ObjectEntryNameLength>6</ObjectEntryNameLength>
    <Source>request</Source>
    <StringValueLength>50</StringValueLength>
</JSONThreatProtection>

超過容器深度

錯誤回應主體

執行階段流量會傳回 500 回應代碼,並顯示以下錯誤:

{
    "fault": {
        "faultstring": "JSONThreatProtection[policy_name]:
          Execution failed. reason: JSONThreatProtection[policy_name]:
          Exceeded container depth at line line-num",
        "detail": {
            "errorcode": "steps.jsonthreatprotection.ExecutionFailed"
        }
    }
}

錯誤回應主體範例

{
    "fault": {
        "faultstring": "JSONThreatProtection[JSON-Threat-Protection-1]:
          Execution failed. reason: JSONThreatProtection[JSON-Threat-Protection-1]:
          Exceeded container depth at line 5",
        "detail": {
            "errorcode": "steps.jsonthreatprotection.ExecutionFailed"
        }
    }
}

原因

如果 <Source> 元素指定的輸入訊息酬載包含 JSON 物件,且該物件的容器深度已超過政策 <ContainerDepth> 元素中指定的容器深度,就會發生這個錯誤。容器深度是 JSON 元素允許的巢狀深度上限。舉例來說,如果陣列中的物件含有物件,則所含物件收錄深度為 3。

舉例來說,如果 <ContainerDepth> 元素為 3,但輸入酬載的容器深度超過此限制,系統就會擲回這個錯誤。

診斷

  1. 檢查錯誤訊息,找出 JSONThreatProtection 政策名稱和超出容器深度的行號。例如,在下列錯誤訊息中,政策名稱是 JSON-Threat-Protection-1,酬載中的行號為 5

    JSONThreatProtection[JSON-Threat-Protection-1]: Execution failed. reason:
    JSONThreatProtection[JSON-Threat-Protection-1]: Exceeded container depth at
    line 5
    
  2. 記下 <ContainerDepth> 元素指定的值 (於步驟 1 識別)。

    在以下 JSONThreatProtection 政策範例中,<ContainerDepth> 設為 5

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <JSONThreatProtection async="false" continueOnError="false" enabled="true" name="JSON-Threat-Protection-1">
        <DisplayName>JSON Threat Protection-1</DisplayName>
        <Properties/>
        <ArrayElementCount>3</ArrayElementCount>
        <ContainerDepth>5</ContainerDepth>
        <ObjectEntryCount>5</ObjectEntryCount>
        <ObjectEntryNameLength>20</ObjectEntryNameLength>
        <Source>request</Source>
        <StringValueLength>50</StringValueLength>
    </JSONThreatProtection>
    
  3. 檢查輸入酬載的特定行號 (如步驟 1 所示),並檢查酬載中的容器深度是否高於 <ContainerDepth> 元素中指定的值 (如步驟 2 所示)。如果容器深度超過計數,這就是錯誤的原因。

    以下是輸入酬載的範例:

    {
     "ContainerDepth2":[ {
           "ContainerDepth4":[
              {
                 "ContainerDepth6":[
                    "1",
                    "2"
                 ]
              }
           ]
        }
     ]
    }
    

    上方顯示的 JSON 酬載在第 5 行的容器深度為 6。由於深度大於 5,因此 JSONThreatProtection 政策的 <ContainerDepth> 元素指定值會產生下列錯誤:

    JSONThreatProtection[JSON-Threat-Protection-1]: Execution failed. reason:
    JSONThreatProtection[JSON-Threat-Protection-1]: Exceeded container depth at
    line 5
    

解析度

如果 JSONThreatProtection 政策的用意是防範容器深度超過指定值的酬載,則預期會顯示錯誤訊息。在這種情況下,您不需要採取其他動作。

不過,如果您判斷可接受的容器深度較高,請根據您的需求,將 <ContainerDepth> 修改為適當的值。

舉例來說,如果您認為您可以允許高達 10 的容器深度,請依下列方式修改政策:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<JSONThreatProtection async="false" continueOnError="false" enabled="true" name="JSON-Threat-Protection-1">
    <DisplayName>JSON Threat Protection-1</DisplayName>
    <Properties/>
    <ArrayElementCount>3</ArrayElementCount>
    <ContainerDepth>10</ContainerDepth>
    <ObjectEntryCount>5</ObjectEntryCount>
    <ObjectEntryNameLength>20</ObjectEntryNameLength>
    <Source>request</Source>
    <StringValueLength>50</StringValueLength>
</JSONThreatProtection>

超過字串值長度

錯誤回應主體

{
    "fault": {
        "faultstring": "JSONThreatProtection[policy_name]:
          Execution failed. reason: JSONThreatProtection[policy_name]:
          Exceeded string value length at line line-num",
        "detail": {
            "errorcode": "steps.jsonthreatprotection.ExecutionFailed"
        }
    }
}

錯誤回應主體範例

{
    "fault": {
        "faultstring": "JSONThreatProtection[JSON-Threat-Protection-1]:
          Execution failed. reason: JSONThreatProtection[JSON-Threat-Protection-1]:
          Exceeded string value length at line 3",
        "detail": {
            "errorcode": "steps.jsonthreatprotection.ExecutionFailed"
        }
    }
}

原因

如果 <Source> 元素指定的輸入訊息酬載包含 JSON 元素,其值所含的字元超過 <StringValueLength> 元素所允許的上限,就會發生這個錯誤。

舉例來說,如果政策中的 <StringValueLength> 元素設為 50,但輸入酬載有一或多個元素的值包含超過 50 個半形字元,系統就會擲回這個錯誤。

診斷

  1. 檢查錯誤訊息,找出政策名稱和超出字串長度的行號。在以下範例中,政策名稱在酬載 3 中為 JSON-Threat-Protection-1 and 行。

    JSONThreatProtection[JSON-Threat-Protection-1]: Execution failed. reason:
    JSONThreatProtection[JSON-Threat-Protection-1]: Exceeded string value length at line 3
    
  2. 記下在步驟 1 中為 <StringValueLength> 元素指定的值。

    在以下 JSONThreatProtection 政策範例中,<StringValueLength> 設為 50

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <JSONThreatProtection async="false" continueOnError="false" enabled="true" name="JSON-Threat-Protection-1">
        <DisplayName>JSON Threat Protection-1</DisplayName>
        <Properties/>
        <ArrayElementCount>3</ArrayElementCount>
        <ContainerDepth>5</ContainerDepth>
        <ObjectEntryCount>5</ObjectEntryCount>
        <ObjectEntryNameLength>20</ObjectEntryNameLength>
        <Source>request</Source>
        <StringValueLength>50</StringValueLength>
    </JSONThreatProtection>
    
  3. 檢查輸入酬載的特定行號 (如步驟 1 所示),並檢查值的長度是否超過您為 <StringValueLength> 元素指定的字元數 (如步驟 2 所示)。如果值的長度超過上限,就會導致錯誤發生。

    以下是輸入酬載的範例:

    {
      "Country": "New Zealand",
      "Place Name": "Taumatawhakatangihangakoauauotamateaturipukakapikimaungahoronukupokaiwhenuakitanatahu"
    }
    

    上方顯示的 JSON 酬載中有一個名為 Place Name 的物件,其值 Taumatawhakatangihangakoauauotamateaturipukakapikimaungahoronukupokaiwhenuakitanatahu 在第 3 行含有 85 個字元。由於值的長度大於 50 (也就是 <StringValueLength> 元素中指定的值),您會收到以下錯誤:

    JSONThreatProtection[JSON-Threat-Protection-1]: Execution failed. reason:
    JSONThreatProtection[JSON-Threat-Protection-1]: Exceeded string value length
    at line 3
    

解析度

如果 JSONThreatProtection 政策的用意是防範值超過特定字串長度的酬載,則預期會出現錯誤訊息。在這種情況下,您不需要採取其他動作。

但是,如果您確定可以在酬載中指定較長的值長度,請根據需求將 <StringValueLength> 修改為適當的值。

舉例來說,如果您認為您可以允許長度上限為 90 的值,請按照以下方式修改政策:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<JSONThreatProtection async="false" continueOnError="false" enabled="true" name="JSON-Threat-Protection-1">
    <DisplayName>JSON Threat Protection-1</DisplayName>
    <Properties/>
    <ArrayElementCount>3</ArrayElementCount>
    <ContainerDepth>5</ContainerDepth>
    <ObjectEntryCount>5</ObjectEntryCount>
    <ObjectEntryNameLength>20</ObjectEntryNameLength>
    <Source>request</Source>
    <StringValueLength>90</StringValueLength>
</JSONThreatProtection>

JSON 物件無效

錯誤回應主體

{
    "fault": {
        "faultstring": "JSONThreatProtection[policy_name]:
          Execution failed. reason: string: at line line-num",
        "detail": {
            "errorcode": "steps.jsonthreatprotection.ExecutionFailed"
        }
    }
}

錯誤回應主體範例

{
    "fault": {
        "faultstring": "JSONThreatProtection[JSON-Threat-Protection-1]:
          Execution failed. reason: Expecting : at line 3",
        "detail": {
            "errorcode": "steps.jsonthreatprotection.ExecutionFailed"
        }
    }
}

原因

如果 JSONThreatProtection 政策中 <Source> 元素指定的輸入訊息酬載不是有效的 JSON 物件,就會發生這個錯誤。

診斷

  1. 查看錯誤訊息,找出發生錯誤的政策名稱和行號。在以下範例中,政策名稱在酬載 2 中為 JSON-Threat-Protection-1 and 行。

    JSONThreatProtection[JSON-Threat-Protection-1]: Execution failed. reason: Expecting : at line 3
    
  2. 檢查輸入酬載的特定行號 (識別於步驟 1),並檢查酬載中傳遞的 JSON 物件是否確實是有效的 JSON 物件。

    以下是輸入酬載的範例:

    {
      "Longitude": 6.11499,
      "Latitude"  50.76891
    }
    

    在上方顯示的 JSON 酬載中,第 3 行沒有 ":" (冒號),這不是有效的 JSON 物件,因此系統會顯示錯誤訊息:

    JSONThreatProtection[JSON-Threat-Protection-1]: Execution failed. reason:
    Expecting : at line 3
    

解析度

確保將有效的輸入 JSON 酬載傳遞至包含 JSONThreatProtection 政策的任何 API Proxy。

針對上述範例,請按照下列步驟修改 JSON 酬載:

{
    "Longitude": 6.11499,
  "Latitude" : 50.76891
}

SourceUnavailable

錯誤代碼

steps.jsonthreatprotection.SourceUnavailable

錯誤回應主體

{
    "fault": {
        "faultstring": "JSONThreatProtection[policy_name]::
          Source[var_name] is not available"
        "detail": {
            "errorcode": "steps.jsonthreatprotection.SourceUnavailable"
        }
    }
}

錯誤回應主體範例

{
    "fault": {
        "faultstring": "JSONThreatProtection[JSON-Threat-Protection-1]::
          Source requests is not available",
        "detail": {
            "errorcode": "steps.jsonthreatprotection.SourceUnavailable"
        }
    }
}

原因

如果在 JSONThreatProtection 政策的 <Source> 元素中指定 message 變數,就會發生這個錯誤:

  • 超出範圍 (不適用於執行政策的特定流程)
  • 不是有效的值 requestresponsemessage

例如,如果政策中的 <Source> 元素設為某個變數,但該變數並未存在於執行政策的流程中,就會發生此錯誤。

診斷

  1. 識別政策名稱,以及錯誤訊息中的來源變數名稱。舉例來說,在下列錯誤訊息中,政策名稱為 JSON-Threat-Protection-1,來源變數則為 requests

    JSONThreatProtection[JSON-Threat-Protection-1]:: Source requests is not available
    
  2. 檢查您在步驟 1 中識別的 <Source> 元素指定的值。

    在以下 JSONThreatProtection 政策範例中,<Source> 元素已設為 requests

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <JSONThreatProtection async="false" continueOnError="false" enabled="true" name="JSON-Threat-Protection-1">
        <DisplayName>JSON Threat Protection-1</DisplayName>
        <Properties/>
        <ArrayElementCount>3</ArrayElementCount>
        <ContainerDepth>5</ContainerDepth>
        <ObjectEntryCount>5</ObjectEntryCount>
        <ObjectEntryNameLength>20</ObjectEntryNameLength>
        <Source>requests</Source>
        <StringValueLength>50</StringValueLength>
    </JSONThreatProtection>
    

    <Source> 元素的有效值為 requestresponsemessage。由於要求的值並非有效值,而且不在執行政策的流程中,因此您會收到錯誤訊息:

    JSONThreatProtection[JSON-Threat-Protection-1]:: Source requests is not available
    

解析度

針對失敗的 JSONThreatProtection 政策,請確定將 <Source> 元素中設定的變數設為 requestresponsemessage,並存在於政策執行流程中。

如要修正上述 JSONThreatProtection 政策示例,您可以將 <Source> 元素修改為使用 request 變數,因為該變數存在於要求流程中:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<JSONThreatProtection async="false" continueOnError="false" enabled="true" name="JSON-Threat-Protection-1">
    <DisplayName>JSON Threat Protection-1</DisplayName>
    <Properties/>
    <ArrayElementCount>3</ArrayElementCount>
    <ContainerDepth>5</ContainerDepth>
    <ObjectEntryCount>5</ObjectEntryCount>
    <ObjectEntryNameLength>20</ObjectEntryNameLength>
    <Source>request</Source>
    <StringValueLength>50</StringValueLength>
</JSONThreatProtection>

NonMessageVariable

錯誤代碼

steps.jsonthreatprotection.NonMessageVariable

錯誤回應主體

{
    "fault": {
        "faultstring": "JSONThreatProtection[policy_name]:
          Variable var_name does not resolve to a Message"
        "detail": {
            "errorcode": "steps.jsonthreatprotection.NonMessageVariable"
        }
    }
}

錯誤回應主體範例

{
    "fault": {
        "faultstring": "JSONThreatProtection[JSON-Threat-Protection-1]:
          Variable message.content does not resolve to a Message",
        "detail": {
            "errorcode": "steps.jsonthreatprotection.NonMessageVariable"
        }
    }
}

原因

如果 JSONThreatProtection 政策中的 <Source> 元素設為不屬於 message 類型的變數,就會發生這個錯誤。

訊息類型變數代表整個 HTTP 要求和回應。內建的 Apigee Edge 流程變數要求、回應和訊息屬於類型訊息。如要進一步瞭解訊息變數,請參閱「變數參考資料」。

診斷

  1. 識別錯誤訊息中的 JSONThreatProtection 政策名稱和來源變數名稱。舉例來說,在下列錯誤訊息中,政策名稱為 JSON-Threat-Protection-1,來源變數則為 message.content

    JSONThreatProtection[JSON-Threat-Protection-1]: Variable message.content does not resolve to a Message
    
  2. 檢查 JSONThreatProtection 政策的 <Source> 元素 (可在步驟 1 中找到)。

    在以下 JSONThreatProtection 政策範例中,<Source> 設為 message.content,而非 message

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <JSONThreatProtection async="false" continueOnError="false" enabled="true" name="JSON-Threat-Protection-1">
        <DisplayName>JSON Threat Protection-1</DisplayName>
        <Properties/>
        <ArrayElementCount>3</ArrayElementCount>
        <ContainerDepth>5</ContainerDepth>
        <ObjectEntryCount>5</ObjectEntryCount>
        <ObjectEntryNameLength>20</ObjectEntryNameLength>
        <Source>message.content</Source>
        <StringValueLength>50</StringValueLength>
    </JSONThreatProtection>
    

    由於 message.content 不是訊息類型,所以您會收到以下錯誤訊息:

    JSONThreatProtection[JSON-Threat-Protection-1]: Variable message.content does
    not resolve to a Message
    

解析度

確認失敗的 JSONThreatProtection 政策中的 <Source> 元素,設為「message」類型資料流變數,這個變數存在於執行政策的流程中。

如要修正政策,您可以修改 <Source> 元素以指定訊息類型的變數。例如,在失敗的 JSONThreatProtection 中,您可以將 <Source> 元素指定為 message

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<JSONThreatProtection async="false" continueOnError="false" enabled="true" name="JSON-Threat-Protection-1">
    <DisplayName>JSON Threat Protection-1</DisplayName>
    <Properties/>
    <ArrayElementCount>3</ArrayElementCount>
    <ContainerDepth>5</ContainerDepth>
    <ObjectEntryCount>5</ObjectEntryCount>
    <ObjectEntryNameLength>20</ObjectEntryNameLength>
    <Source>message</Source>
    <StringValueLength>50</StringValueLength>
</JSONThreatProtection>