您目前查看的是 Apigee 和 Apigee Hybrid 說明文件。
查看
Apigee Edge 說明文件。
InvalidRegularExpression
錯誤訊息
透過 Apigee 使用者介面或 API 部署 API Proxy 時失敗,並顯示以下錯誤訊息:
Error Deploying Revision revision_number to environment RegularExpressionProtection policy_name: Invalid Regular Expression com.apigee.steps.regexprotection.RegularExpressionProtectionBean$RegexPattern@f4ecb23, Context Revision:revision_number;APIProxy:RegexThreat;Organization:organization;Environment:environment.
錯誤訊息範例
Error Deploying Revision 1 to test RegularExpressionProtection Regular-Expression-Protection-1: Invalid Regular Expression com.apigee.steps.regexprotection.RegularExpressionProtectionBean$RegexPattern@f4ecb23, Context Revision:1;APIProxy:RegexThreat;Organization:myorg;Environment:test.
錯誤螢幕截圖範例

原因
如果 RegularExpressionProtection 政策的 <Pattern> 元素中的規則運算式無效,API Proxy 的部署作業就會失敗。
診斷
從錯誤訊息中找出 RegularExpressionProtection 政策的名稱。舉例來說,在下列錯誤中,「RegularExpressionProtection policy」名稱為
Regular-Expression-Protection-1:Error Deploying Revision 1 to test RegularExpressionProtection Regular-Expression-Protection-1: Invalid Regular Expression com.apigee.steps.regexprotection.RegularExpressionProtectionBean$RegexPattern@f4ecb23, Context Revision:1;APIProxy:RegexThreat;Organization:myorg;Environment:test.
檢查失敗的規則運算式防護政策 XML 中的所有
<Pattern>元素。檢查是否有任何<Pattern>元素含有無效的規則運算式。如果任何<Pattern>元素含有無效的規則運算式,就會導致錯誤。舉例來說,下列政策指定
Pattern>的foo){2}值,這會視為無效的規則運算式:<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <RegularExpressionProtection async="false" continueOnError="false" enabled="true" name="Regular-Expression-Protection-1"> <DisplayName>Regular Expression Protection-1</DisplayName> <Properties/> <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables> <URIPath> <Pattern>foo){2}</Pattern> </URIPath> <Source>request</Source> </RegularExpressionProtection>在上述範例中,
<Pattern>中指定的規則運算式缺少左括號。因此系統會將其視為無效的規則運算式。因此 API Proxy 部署作業會失敗。
解析度
請確保 RegularExpressionProtection 政策中的每個 <Pattern> 元素都包含有效的規則運算式。您可以搜尋不同的線上或離線規則運算式工具,偵錯規則運算式。
如要修正上述規則運算式保護政策範例,請新增缺少的半形括號:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<RegularExpressionProtection async="false" continueOnError="false" enabled="true" name="Regular-Expression-Protection-1">
<DisplayName>Regular Expression Protection-1</DisplayName>
<Properties/>
<IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
<URIPath>
<Pattern>(foo){2}</Pattern>
</URIPath>
<Source>request</Source>
</RegularExpressionProtection>XPathCompilationFailed
錯誤訊息
透過 Apigee 使用者介面或 API 部署 API Proxy 時失敗,並顯示以下錯誤訊息:
Error Deploying Revision revision_number to environment RegularExpressionProtection policy_name: Failed to compile xpath xpath_expression. Context Revision:revision_number;APIProxy:RegexThreat;Organization:organization;Environment:environment.
錯誤訊息範例
Error Deploying Revision 1 to test RegularExpressionProtection Regular-Expression-Protection-1: Failed to compile xpath /notapigee:foo/notapigee:bar. Context Revision:1;APIProxy:RegexThreat;Organization:myorg;Environment:test.
錯誤螢幕截圖範例

原因
如果 <XPath> 元素中使用的前置字元或值不屬於RegularExpressionProtection 政策中宣告的任何命名空間,API Proxy 的部署作業就會失敗。
如要進一步瞭解命名空間、XPath 和前置字元,請參閱「XML Namespaces and How They Affect XPath and XSLT」。
診斷
找出發生錯誤的 RegularExpressionProtection 政策名稱,以及使用的 XPath 運算式。您可以在錯誤訊息中找到這兩項資訊。
舉例來說,在下列錯誤中,政策名稱為
Regular-Expression-Protection-1,XPath 運算式為/notapigee:foo/notapigee:bar:Error Deploying Revision 1 to test RegularExpressionProtection Regular-Expression-Protection-1: Failed to compile xpath /notapigee:foo/notapigee:bar. Context Revision:1;APIProxy:RegexThreat;Organization:myorg;Environment:test.
在失敗的規則運算式保護政策 XML 中,確認
Expression元素中設定的 XPath 與錯誤訊息中識別的 XPath (上述步驟 1) 相符。舉例來說,下列政策將 XPath 指定為
/notapigee:foo/notapigee:bar,與錯誤訊息中的內容相符:<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <RegularExpressionProtection async="false" continueOnError="false" enabled="true" name="Regular-Expression-Protection-1"> <DisplayName>Regular Expression Protection-1</DisplayName> <Properties/> <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables> <Source>request</Source> <XMLPayload> <Namespaces> <Namespace prefix="apigee">http://www.apigee.com</Namespace> </Namespaces> <XPath> <Expression>/notapigee:foo/notapigee:bar</Expression> <Type>nodeset</Type> <Pattern>pattern</Pattern> <Pattern>pattern2</Pattern> </XPath> </XMLPayload> </RegularExpressionProtection>
- 檢查 RegularExpressionProtection 政策中的
<Namespaces>和<Expression>元素。如果錯誤訊息中指出的特定<Expression>使用的前置字元或值,不屬於RegularExpressionProtection 政策中宣告的命名空間,就會導致錯誤。請注意,範例 RegularExpressionProtection 政策中的特定
<XPath>使用了前置字元notapigee:<Expression>/notapigee:foo/notapigee:bar</Expression>
不過,前置字串
notapigee並未在任何<Namespace>元素中定義,因此<XPath>的編譯作業會失敗,導致部署作業失敗。
解析度
請確認 <XPath> 元素下 <Expression> 元素中使用的所有命名空間,都已在 RegularExpressionProtection 政策中聲明。如要修正上述範例,您可以將 notapigee 前置字串替換為 apigee,後者是在命名空間中宣告:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <RegularExpressionProtection async="false" continueOnError="false" enabled="true" name="Regular-Expression-Protection-1"> <DisplayName>Regular Expression Protection-1</DisplayName> <Properties/> <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables> <Source>request</Source> <XMLPayload> <Namespaces> <Namespace prefix="apigee">http://www.apigee.com</Namespace> </Namespaces> <XPath> <Expression>/apigee:foo/apigee:bar</Expression> <Type>nodeset</Type> <Pattern>pattern</Pattern> <Pattern>pattern2</Pattern> </XPath> </XMLPayload> </RegularExpressionProtection>
CannotBeConvertedToNodeset
錯誤訊息
透過 Apigee 使用者介面或 API 部署 API Proxy 時失敗,並顯示以下錯誤訊息:
Error Deploying Revision revision_number to environment RegularExpressionProtection policy_name: Result of xpath xpath_expression cannot be converted to nodeset. Context Revision:revision_number;APIProxy:RegexThreat;Organization:organization;Environment:environment.
錯誤訊息範例
Error Deploying Revision 1 to test RegularExpressionProtection Regular-Expression-Protection-1: Result of xpath count(//apigee:foo) cannot be converted to nodeset. Context Revision:1;APIProxy:RegexThreat;Organization:myorg;Environment:test.
錯誤螢幕截圖範例

原因
如果規則運算式政策的 <XPath> 運算式中,<Type> 元素定義為 nodeset,但運算式無法轉換為 nodeset,則 API 代理伺服器部署作業會失敗。
診斷
找出發生錯誤的 RegularExpressionProtection 政策,以及無法轉換為節點集的 XPath 運算式。您可以在錯誤訊息中找到這兩項資訊。
舉例來說,在下列錯誤中,政策名稱為
Regular-Expression-Protection-1,XPath 運算式為count(//apigee:foo):Error Deploying Revision 1 to test RegularExpressionProtection Regular-Expression-Protection-1: Result of xpath count(//apigee:foo) cannot be converted to nodeset. Context Revision:1;APIProxy:RegexThreat;Organization:myorg;Environment:test.
在失敗的規則運算式保護政策 XML 中,確認
<XPath>元素的<Expression>元素中設定的 XPath,與錯誤訊息中識別的 XPath (上述步驟 1) 相符。舉例來說,下列政策將 as 指定為
count(//apigee:foo),與錯誤訊息中的內容相符:<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <RegularExpressionProtection async="false" continueOnError="false" enabled="true" name="Regular-Expression-Protection-1"> <DisplayName>Regular Expression Protection-1</DisplayName> <Properties/> <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables> <Source>request</Source> <XMLPayload> <Namespaces> <Namespace prefix="apigee">http://www.apigee.com</Namespace> </Namespaces> <XPath> <Expression>count(//apigee:foo)</Expression> <Type>nodeset</Type> <Pattern>pattern</Pattern> <Pattern>pattern2</Pattern> </XPath> </XMLPayload> </RegularExpressionProtection>
檢查
<XPath>元素下方的<Type>元素中設定的值。如果<Type>元素為nodeset,則這是錯誤原因。在這個範例中,XPath 運算式為 count(),不會傳回一或多個節點。因此 API Proxy 部署作業會失敗。
解析度
如果 <Type> 元素設為節點集,請確保 <XPath> 中設定的 <Expression> 元素集結果為一或多個節點。或者,根據您的用途,將 <Type> 元素變更為更適當的值。
如要修正上述範例,您可以將 <Expression> 元素變更為可傳回節點的不同值:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <RegularExpressionProtection async="false" continueOnError="false" enabled="true" name="Regular-Expression-Protection-1"> <DisplayName>Regular Expression Protection-1</DisplayName> <Properties/> <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables> <Source>request</Source> <XMLPayload> <Namespaces> <Namespace prefix="apigee">http://www.apigee.com</Namespace> </Namespaces> <XPath> <Expression>/apigee:foo/apigee:bar</Expression> <Type>nodeset</Type> <Pattern>pattern</Pattern> <Pattern>pattern2</Pattern> </XPath> </XMLPayload> </RegularExpressionProtection>
JSONPathCompilationFailed
錯誤訊息
透過 Apigee 使用者介面或 API 部署 API Proxy 時失敗,並顯示以下錯誤訊息:
Error Deploying Revision revision_number to environment RegularExpressionProtection policy_name: Failed to compile jsonpath jsonpath_expression Context Revision:revision_number;APIProxy:RegexThreat;Organization:organization;Environment:environment.
錯誤訊息範例
Error Deploying Revision 1 to test RegularExpressionProtection Regular-Expression-Protection-1: Failed to compile jsonpath $.store.book[*.author. Context Revision:1;APIProxy:RegexThreat;Organization:myorg;Environment:test.
錯誤螢幕截圖範例

原因
如果規則運算式保護政策的 <JSONPath> 元素下方的 <Expression> 元素設為無效的 JSONPath 運算式,API Proxy 的部署作業就會失敗。
診斷
找出發生錯誤的 RegularExpressionProtection 政策名稱,以及使用的無效 JSONPath 運算式。您可以在錯誤訊息中找到這兩項資訊。
舉例來說,在下列錯誤中,政策名稱為
Regular-Expression-Protection-1,JSONPath 運算式為$.store.book[*.author:Error Deploying Revision 1 to test RegularExpressionProtection Regular-Expression-Protection-1: Failed to compile jsonpath $.store.book[*.author. Context Revision:1;APIProxy:RegexThreat;Organization:myorg;Environment:test.
在失敗的 Regular Expression Protection 政策 XML 中,確認
Expression元素中設定的 JSONPath 與錯誤訊息中識別的 JSONPath (上述步驟 1) 相符。舉例來說,下列政策會在
<JSONPath>元素下將Expression元素指定為$.store.book[*.author,這與錯誤訊息中的內容相符:<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <RegularExpressionProtection async="false" continueOnError="false" enabled="true" name="Regular-Expression-Protection-1"> <DisplayName>Regular Expression Protection-1</DisplayName> <Properties/> <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables> <Source>request</Source> <JSONPayload> <JSONPath> <Expression>$.store.book[*.author</Expression> <Pattern>REGEX PATTERN</Pattern> <Pattern>REGEX PATTERN</Pattern> </JSONPath> </JSONPayload> </RegularExpressionProtection>
詳閱政策中
<JSONPath>元素下的<Expression>元素。如果與 JSONPath 語法不符,這就是錯誤原因。在上述範例中,缺少右方括號,因此運算式無效。由於 JSON 路徑運算式無效,API Proxy 部署作業會失敗。
解析度
確認 Regular Expression Protection 政策中 <JSONPath> 元素內的 <Expression> 元素值是有效的 JSONPath 運算式。
如要修正上述範例,可以在 <Expression> 元素值中加入缺少的右方括號:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <RegularExpressionProtection async="false" continueOnError="false" enabled="true" name="Regular-Expression-Protection-1"> <DisplayName>Regular Expression Protection-1</DisplayName> <Properties/> <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables> <Source>request</Source> <JSONPayload> <JSONPath> <Expression>$.store.book[*].author</Expression> <Pattern>REGEX PATTERN</Pattern> <Pattern>REGEX PATTERN</Pattern> </JSONPath> </JSONPayload> </RegularExpressionProtection>
NothingToEnforce
錯誤訊息
透過 Apigee 使用者介面或 API 部署 API Proxy 時失敗,並顯示以下錯誤訊息:
Error Saving Revision revision_number RegularExpressionProtection policy_name: at least one of URIPath, QueryParam, Header, FormParam, XMLPayload, JSONPayload is mandatory.
錯誤訊息範例
Error Saving Revision 1 RegularExpressionProtection Regular-Expression-Protection-1: at least one of URIPath, QueryParam, Header, FormParam, XMLPayload, JSONPayload is mandatory.
錯誤螢幕截圖範例

原因
如果 RegularExpressionProtection 政策沒有任何 <URIPath>、<QueryParam>、<Header>、<FormParam>、<XMLPayload> 或 <JSONPayload> 元素,API Proxy 的部署作業就會失敗。
如錯誤訊息所示,RegularExpressionProtection 政策必須至少包含下列其中一個元素:<URIPath>、<QueryParam>、<Header>、<FormParam>、<XMLPayload> 或 <JSONPayload>。
診斷
找出發生錯誤的 RegularExpressionProtection 政策名稱。您可以在錯誤訊息中找到正確的網址,舉例來說,在下列錯誤中,政策名稱為
Regular-Expression-Protection-1:RegularExpressionProtection Regular-Expression-Protection-1: at least one of URIPath, QueryParam, Header, FormParam, XMLPayload, JSONPayload is mandatory.
檢查失敗的規則運算式防護政策 (如上述步驟 1 所示)。如果政策缺少
<URIPath>、<QueryParam>、<Header>、<FormParam>、<XMLPayload>或<JSONPayload>元素,就會導致錯誤。舉例來說,下列規則運算式保護政策不含上述任何元素:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <RegularExpressionProtection async="false" continueOnError="false" enabled="true" name="Regular-Expression-Protection-1"> <DisplayName>Regular Expression Protection-1</DisplayName> <Properties/> <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables> <Source>request</Source> </RegularExpressionProtection>由於 Extract Variables 政策中沒有任何必要元素,因此 API Proxy 部署作業會失敗。
解析度
請確認 RegularExpressionProtection 政策至少包含下列其中一個必要元素:<URIPath>、<QueryParam>、<Header>、<FormParam>、<XMLPayload> 或 <JSONPayload>。例如:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <RegularExpressionProtection async="false" continueOnError="false" enabled="true" name="Regular-Expression-Protection-1"> <DisplayName>Regular Expression Protection-1</DisplayName> <Properties/> <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables> <Source>request</Source> <JSONPayload> <JSONPath> <Expression>$.store.book[*].author</Expression> <Pattern>REGEX PATTERN</Pattern> <Pattern>REGEX PATTERN</Pattern> </JSONPath> </JSONPayload> </RegularExpressionProtection>
NoPatternsToEnforce
錯誤訊息
透過 Apigee 使用者介面或 API 部署 API Proxy 時失敗,並顯示以下錯誤訊息:
Error Saving Revision revision_number RegularExpressionProtection policy_name: No patterns to enforce in payload_name.
錯誤訊息範例
Error Saving Revision 1 RegularExpressionProtection Regular-Expression-Protection-1: No patterns to enforce in XPath.
錯誤螢幕截圖範例

原因
如果任何頂層元素 (<URIPath>、<QueryParam>、<Header>、<FormParam>、<XMLPayload> 或 <JSONPayload>) 未在 RegularExpressionProtection 政策中定義 <Pattern> 元素,API 代理的部署作業就會失敗。
診斷
找出發生錯誤的 RegularExpressionProtection 政策名稱,以及沒有
<Pattern>元素的子系元素。您可以在錯誤訊息中找到這兩項資訊。舉例來說,在下列錯誤中,政策名稱為
Regular-Expression-Protection-1,子項元素為XPath:RegularExpressionProtection Regular-Expression-Protection-1: No patterns to enforce in XPath.
- 檢查失敗的「Regular Expression Protection」政策,確認步驟 1 中識別的子項元素是否沒有
<Pattern>元素。如果其中沒有<Pattern>元素,就是造成錯誤的原因。舉例來說,下列政策的
<XPath>內沒有<Pattern>元素:<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <RegularExpressionProtection async="false" continueOnError="false" enabled="true" name="Regular-Expression-Protection-1"> <DisplayName>Regular Expression Protection-1</DisplayName> <Properties/> <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables> <Source>request</Source> <XMLPayload> <Namespaces> <Namespace prefix="apigee">http://www.apigee.com</Namespace> </Namespaces> <XPath> <Expression>/apigee:Greeting/apigee:User</Expression> <Type>string</Type> </XPath> </XMLPayload> </RegularExpressionProtection>
由於
<XPath>元素沒有<Pattern>元素,API Proxy 部署作業會失敗。
解析度
請確認 <URIPath>、<QueryParam>、<Header>、<FormParam>、<XMLPayload> 或 <JSONPayload> 元素至少指定一個 <Pattern>。如要瞭解如何正確指定元素,請參閱 RegularExpressionProtection 政策。
如要修正上述範例,只要在 <XMLPayload> 底下的 <XPath> 元素中加入 <Pattern> 元素即可:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <RegularExpressionProtection async="false" continueOnError="false" enabled="true" name="Regular-Expression-Protection-1"> <DisplayName>Regular Expression Protection-1</DisplayName> <Properties/> <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables> <Source>request</Source> <XMLPayload> <Namespaces> <Namespace prefix="apigee">http://www.apigee.com</Namespace> </Namespaces> <XPath> <Expression>/apigee:Greeting/apigee:User</Expression> <Type>string</Type> <Pattern>REGEX PATTERN</Pattern> </XPath> </XMLPayload> </RegularExpressionProtection>
NONEmptyPrefixMappedToEmptyURI
錯誤訊息
透過 Apigee 使用者介面或 API 部署 API Proxy 時失敗,並顯示以下錯誤訊息:
Error Saving Revision revision_number RegularExpressionProtection policy_name: Non-empty prefix prefix_name cannot be mapped to empty uri.
錯誤訊息範例
Error Saving Revision 1 RegularExpressionProtection Regular-Expression-Protection-1: Non-empty prefix apigee cannot be mapped to empty uri.
錯誤螢幕截圖範例

原因
如果 RegularExpressionProtection 政策在 <XMLPayload> 元素下的 <Namespace> 元素中定義了前置字元,但未定義 URI,就會發生這個錯誤。
診斷
找出發生錯誤的 RegularExpressionProtection 政策,以及未對應至 URI 的前置字元名稱。您可以在錯誤訊息中找到這兩項資訊。
舉例來說,在下列錯誤中,政策名稱為「Regular Expression Protection-1」,前置字元為「apigee」:
RegularExpressionProtection Regular-Expression-Protection-1: Non-empty prefix apigee cannot be mapped to empty uri.
在失敗的 Regular Expression Protection 政策 XML 中,確認
<XMLPayload>元素下<Namespace>元素中設定的前置字元名稱,與錯誤訊息中識別的前置字元名稱 (上述步驟 1) 相符。舉例來說,下列政策會在
<Namespace>元素中指定名為 apigee 的前置字串,與錯誤訊息中的內容相符:<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <RegularExpressionProtection async="false" continueOnError="false" enabled="true" name="Regular-Expression-Protection-1"> <DisplayName>Regular Expression Protection-1</DisplayName> <Properties/> <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables> <Source>request</Source> <XMLPayload> <Namespaces> <Namespace prefix="apigee"/> <Namespace prefix="gmail">http://mail.google.com</Namespace> </Namespaces> <XPath> <Expression>/apigee:Greeting/apigee:User</Expression> <Type>string</Type> <Pattern>REGEX PATTERN</Pattern> </XPath> </XMLPayload> </RegularExpressionProtection>
驗證在步驟 2 中識別的特定前置字元是否具有有效的 URI。
<Namespace>如果缺少 URI,就是造成錯誤的原因。在上述範例的「Regular Expression Protection」政策中,請注意,沒有對應於前置字元為 apigee 的
<Namespace>元素的 URI,因此您會收到以下錯誤訊息:Non-empty prefix apigee cannot be mapped to empty uri.
解析度
請確認以字首定義的所有 <Namespace> 元素,在「擷取變數」政策中都有對應的 URI。例如:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <RegularExpressionProtection async="false" continueOnError="false" enabled="true" name="Regular-Expression-Protection-1"> <DisplayName>Regular Expression Protection-1</DisplayName> <Properties/> <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables> <Source>request</Source> <XMLPayload> <Namespaces> <Namespace prefix="apigee">http://www.apigee.com</Namespace> <Namespace prefix="gmail">http://mail.google.com</Namespace> </Namespaces> <XPath> <Expression>/apigee:Greeting/apigee:User</Expression> <Type>string</Type> <Pattern>REGEX PATTERN</Pattern> </XPath> </XMLPayload> </RegularExpressionProtection>
DuplicatePrefix
錯誤訊息
透過 Apigee 使用者介面或 API 部署 API Proxy 時失敗,並顯示以下錯誤訊息:
Error Saving Revision revision_number RegularExpressionProtection policy_name: Duplicate prefix prefix_name.
錯誤訊息範例
Error Saving Revision 1 RegularExpressionProtection Regular-Expression-Protection-1: Duplicate prefix apigee.
錯誤螢幕截圖範例

原因
如果 RegularExpressionProtection 政策在 <XMLPayload> 元素下的 <Namespace> 元素中定義了相同前置字元多次,就會發生這項錯誤。
舉例來說,由於前置字元 apigee 定義了兩次,因此會發生這項錯誤,如下所示:
<Namespace prefix="apigee">http://www.apigee.com</Namespace> <Namespace prefix="apigee">http://www.apigee.com</Namespace>
診斷
找出發生錯誤的 RegularExpressionProtection 政策和前置字串名稱。您可以在錯誤訊息中找到這兩項資訊。
舉例來說,在下列錯誤中,政策名稱為「Regular Expression Protection-1」,前置字元為「apigee」:
RegularExpressionProtection Regular-Expression-Protection-1: Duplicate prefix apigee.
在失敗的 Regular Expression Protection 政策 XML 中,確認
<XMLPayload>元素下<Namespace>元素中設定的前置字元名稱,與錯誤訊息中識別的前置字元名稱 (上述步驟 1) 相符。舉例來說,下列政策會在
<Namespace>元素中指定名為 apigee 的前置字串,與錯誤訊息中的內容相符:<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <RegularExpressionProtection async="false" continueOnError="false" enabled="true" name="Regular-Expression-Protection-1"> <DisplayName>Regular Expression Protection-1</DisplayName> <Properties/> <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables> <Source>request</Source> <XMLPayload> <Namespaces> <Namespace prefix="apigee">http://www.apigee.com</Namespace> <Namespace prefix="apigee">http://www.apigee.com</Namespace> </Namespaces> <XPath> <Expression>/apigee:Greeting/apigee:User</Expression> <Type>string</Type> <Pattern>REGEX PATTERN</Pattern> </XPath> </XMLPayload> </RegularExpressionProtection>
判斷是否已多次定義具有特定前置字元的
<Namespace>元素 (步驟 2 中識別)。如果定義超過一次,就是造成錯誤的原因。在上述的規則運算式保護政策範例中,請注意前置字串為 apigee 的
<Namespace>元素已定義兩次,因此您會收到下列錯誤訊息:Duplicate prefix apigee.
解析度
請確保 RegularExpressionProtection 政策的 <Namespace> 元素中,每個前置字元只有一個定義。例如:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <RegularExpressionProtection async="false" continueOnError="false" enabled="true" name="Regular-Expression-Protection-1"> <DisplayName>Regular Expression Protection-1</DisplayName> <Properties/> <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables> <Source>request</Source> <XMLPayload> <Namespaces> <Namespace prefix="apigee">http://www.apigee.com</Namespace> </Namespaces> <XPath> <Expression>/apigee:Greeting/apigee:User</Expression> <Type>string</Type> <Pattern>REGEX PATTERN</Pattern> </XPath> </XMLPayload> </RegularExpressionProtection>
EmptyXPathExpression
錯誤訊息
透過 Apigee 使用者介面或 API 部署 API Proxy 時失敗,並顯示以下錯誤訊息:
Error Saving Revision revision_number RegularExpressionProtection policy_name: Empty XPath expression.
錯誤訊息範例
Error Saving Revision 1 RegularExpressionProtection Regular-Expression-Protection-1: Empty XPath expression.
錯誤螢幕截圖範例

原因
如果 RegularExpressionProtection 政策的 <XPath> 元素中未設定 <Expression> 元素,API Proxy 的部署作業就會失敗。
診斷
從錯誤訊息中找出失敗的規則運算式防護政策。舉例來說,在下列錯誤中,政策名稱為 Regular-Expression-Protection-1:
RegularExpressionProtection Regular-Expression-Protection-1: Empty XPath expression.
在失敗的 Regular Expression Protection 政策 XML 中,判斷是否有
<XMLPayload>元素含有沒有定義<Expression>元素的<XPath>子元素,或<Expression>元素未設為任何值。如果是,這就是錯誤原因。舉例來說,以下是含有
<XMLPayload>元素的規則運算式保護政策:<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <RegularExpressionProtection async="false" continueOnError="false" enabled="true" name="Regular-Expression-Protection-1"> <DisplayName>Regular Expression Protection-1</DisplayName> <Properties/> <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables> <Source>request</Source> <XMLPayload> <Namespaces> <Namespace prefix="apigee">http://www.apigee.com</Namespace> </Namespaces> <XPath> <Expression></Expression> <Type>string</Type> <Pattern>REGEX PATTERN</Pattern> </XPath> </XMLPayload> </RegularExpressionProtection>
由於
<XPath>元素內有空白的<Expression>元素,API Proxy 部署作業會失敗。
解析度
確認 RegularExpressionProtection 政策的 <XPath> 元素下定義了非空白的有效 <Expression> 元素。例如:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <RegularExpressionProtection async="false" continueOnError="false" enabled="true" name="Regular-Expression-Protection-1"> <DisplayName>Regular Expression Protection-1</DisplayName> <Properties/> <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables> <Source>request</Source> <XMLPayload> <Namespaces> <Namespace prefix="apigee">http://www.apigee.com</Namespace> </Namespaces> <XPath> <Expression>/apigee:Greeting/apigee:User</Expression> <Type>string</Type> <Pattern>REGEX PATTERN</Pattern> </XPath> </XMLPayload> </RegularExpressionProtection>
EmptyJSONPathExpression
錯誤訊息
透過 Apigee 使用者介面或 API 部署 API Proxy 時失敗,並顯示以下錯誤訊息:
Error Saving Revision revision_number RegularExpressionProtection policy_name: Empty JSONPath expression.
錯誤訊息範例
Error Saving Revision 1 RegularExpressionProtection Regular-Expression-Protection-1: Empty JSONPath expression.
錯誤螢幕截圖範例

原因
如果 RegularExpressionProtection 政策的 <JSONPath> 元素中未設定任何 <Expression> 元素,API Proxy 的部署作業就會失敗。
診斷
從錯誤訊息中找出失敗的規則運算式防護政策。舉例來說,在下列錯誤中,政策名稱為 Regular-Expression-Protection-1:
Error Saving Revision 1 RegularExpressionProtection Regular-Expression-Protection-1: Empty JSONPath expression.
在失敗的 Regular Expression Protection 政策 XML 中,判斷是否有
<JSONPayload>元素含有沒有定義<Expression>元素的<JSONPath>子元素,或<Expression>元素未設為任何值。如果是,這就是錯誤原因。舉例來說,以下是包含
<JSONPayload>元素的規則運算式保護政策:<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <RegularExpressionProtection async="false" continueOnError="false" enabled="true" name="Regular-Expression-Protection-1"> <DisplayName>Regular Expression Protection-1</DisplayName> <Properties/> <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables> <Source>request</Source> <JSONPayload> <JSONPath> <Expression></Expression> <Pattern>REGEX PATTERN</Pattern> <Pattern>REGEX PATTERN</Pattern> </JSONPath> </JSONPayload> </RegularExpressionProtection>
由於
<JSONPath>元素內有空白的<Expression>元素,API Proxy 部署作業會失敗。
解析度
確認 RegularExpressionProtection 政策的 <JSONPath> 元素下定義了非空白的有效 <Expression> 元素。例如:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <RegularExpressionProtection async="false" continueOnError="false" enabled="true" name="Regular-Expression-Protection-1"> <DisplayName>Regular Expression Protection-1</DisplayName> <Properties/> <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables> <Source>request</Source> <JSONPayload> <JSONPath> <Expression>$.store.book[*].author</Expression> <Pattern>REGEX PATTERN</Pattern> <Pattern>REGEX PATTERN</Pattern> </JSONPath> </JSONPayload> </RegularExpressionProtection>