查看 Apigee Edge 說明文件。
前往
Apigee X說明文件。 資訊
ExecutionFailed
錯誤代碼
steps.jsonthreatprotection.ExecutionFailed
錯誤回應主體
{ "fault": { "faultstring": "JSONThreatProtection[policy_name ]: Execution failed. reason: JSONThreatProtection[policy_name ]: error_description at lineline_num ", "detail": { "errorcode": "steps.jsonthreatprotection.ExecutionFailed" } } }
錯誤類型和可能原因
JSONThreatProtection 政策可能會擲回許多不同類型的 Execution 失敗錯誤。下表列出各種錯誤類型及可能的原因:
錯誤類型 | 原因 |
超過物件項目名稱長度 | 物件項目名稱過長,超出字串長度上限。 |
超過物件項目數量 | 物件中項目數量已超出上限。 |
超過陣列元素數量 | 超過陣列中允許的元素數量上限。 |
已超過容器深度 | 已超過允許的巢狀深度上限。 |
超過字串值長度 | 字串值超過允許的長度上限。 |
JSON 物件無效 | 輸入的 JSON 酬載無效。 |
超過物件項目名稱長度
錯誤回應主體
{ "fault": { "faultstring": "JSONThreatProtection[policy_name ]: Execution failed. reason: JSONThreatProtection[policy_name ]: Exceeded object entry name length at lineline_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,但輸入訊息酬載含有名稱超過 5 個字元的 JSON 屬性,就會擲回此錯誤。
診斷
檢查錯誤訊息,找出 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
檢查您在步驟 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>
檢查輸入酬載的特定行數 (如步驟 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 lineline_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 個項目,系統就會擲回這個錯誤。
診斷
檢查錯誤訊息,找出 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
記下政策的
<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>
檢查輸入酬載的特定行號 (在步驟 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 lineline-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
,但輸入酬載包含有超過 3 個元素的 JSON 陣列,系統就會擲回這個錯誤。
診斷
查看錯誤訊息,找出政策名稱和超出陣列長度的行號。例如,在下列錯誤訊息中,政策名稱為
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
記下為政策的
<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>
檢查輸入酬載的特定行數 (如步驟 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 lineline-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 物件所含 JSON 元素,而容器深度超過政策 <ContainerDepth>
元素中指定的容器深度上限,就會發生這個錯誤。容器深度是 JSON 元素允許的巢狀深度上限。舉例來說,陣列包含物件,而物件又包含物件,因此包含深度為 3。
舉例來說,如果 <ContainerDepth>
元素為 3
,但輸入酬載的容器深度超過這個上限,系統就會擲回這個錯誤。
診斷
查看錯誤訊息,找出 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
記下為
<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>
檢查輸入酬載的特定行數 (如步驟 1 取得的說明),檢查酬載中的容器深度是否高於
<ContainerDepth>
元素中指定的值 (在步驟 2 中識別)。如果容器深度超過計數,則是錯誤的原因。以下是輸入酬載的範例:
{ "ContainerDepth2":[ { "ContainerDepth4":[ { "ContainerDepth6":[ "1", "2" ] } ] } ] }
上方顯示的 JSON 酬載在第 5 行的容器深度為 6。自深度 大於 5,則為以下
<ContainerDepth>
元素指定的值 JSONThreatProtection 政策會顯示下列錯誤: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 lineline-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 個字元,系統就會擲回這個錯誤。
診斷
查看錯誤訊息,找出政策名稱和超過字串長度的行號。在以下範例中,政策名稱是酬載
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
記下在步驟 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>
檢查輸入酬載的特定行數 (如步驟 1 所示),檢查值的長度是否大於為
<StringValueLength>
元素指定的字元數 (如步驟 2 中所示)。如果值的長度超過上限,就會發生錯誤。以下是輸入酬載的範例:
{ "Country": "New Zealand", "Place Name": "Taumatawhakatangihangakoauauotamateaturipukakapikimaungahoronukupokaiwhenuakitanatahu" }
上方顯示的 JSON 酬載含有名為
Place Name
的物件,其值為Taumatawhakatangihangakoauauotamateaturipukakapikimaungahoronukupokaiwhenuakitanatahu
在第 3 行顯示 85 個字元由於值的長度超過<StringValueLength>
元素中指定的值 50,因此您會收到以下錯誤: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 lineline-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 物件,就會發生這個錯誤。
診斷
查看錯誤訊息,找出政策名稱和發生錯誤的行號。在以下範例中,政策名稱為酬載
2
中的JSON-Threat-Protection-1 and
line。JSONThreatProtection[JSON-Threat-Protection-1]: Execution failed. reason: Expecting : at line 3
檢查輸入酬載的特定行數 (如步驟 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 變數符合下列任一情況,就會發生這個錯誤:
- 超出範圍 (無法在執行政策的特定流程中使用)
- 不是有效的值 (
request
、response
或message
)
舉例來說,如果政策中的 <Source>
元素設為
執行政策的流程中不存在的變數。
診斷
找出政策名稱和錯誤訊息中的來源變數名稱。舉例來說,在下列錯誤訊息中,政策名稱為
JSON-Threat-Protection-1
,來源變數為requests
:JSONThreatProtection[JSON-Threat-Protection-1]:: Source requests is not available
檢查在步驟 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>
元素的有效值為request
、response
或message
。由於 要求不是有效的值,而且不在政策的流程中 執行時,您會看到以下錯誤訊息:JSONThreatProtection[JSON-Threat-Protection-1]:: Source requests is not available
解析度
請確認在失敗的 JSONThreatProtection 政策 <Source>
元素中設定的變數已設為 request
、response
或 message
,且在政策執行的流程中存在。
如要修正上述範例 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 ]: Variablevar_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 流程變數要求、回應和訊息的類型為 message。如要進一步瞭解訊息變數,請參閱變數參考資料。
診斷
找出 JSONThreatProtection 政策名稱和來源變數名稱 錯誤訊息例如,在下列錯誤訊息中,政策名稱 是
JSON-Threat-Protection-1
,而來源變數為message.content
:JSONThreatProtection[JSON-Threat-Protection-1]: Variable message.content does not resolve to a Message
檢查 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>