您正在查看 Apigee Edge 說明文件。
查看 Apigee X 說明文件。 資訊
InvalidRegularExpression
錯誤訊息
無法透過 Edge UI 或 Edge Management 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 政策名稱為
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 部署失敗。
解析度
確認 regexProtection 政策中的每個 <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
錯誤訊息
無法透過 Edge UI 或 Edge Management 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 命名空間以及它們對 XPath 和 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 政策中宣告的命名空間,就會導致發生錯誤。請注意,特定
<XPath>
使用 RegularExpressionProtection 政策範例中的前置字串notapigee
:<Expression>/notapigee:foo/notapigee:bar</Expression>
不過,沒有任何
<Namespace>
元素定義了notapigee
前置字串,因此<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
錯誤訊息
無法透過 Edge UI 或 Edge Management 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 Proxy 部署就會失敗。
診斷
找出發生錯誤的 RegularExpressionProtection 政策,以及無法轉換為 Nodeset 的 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)。舉例來說,下列政策會將
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>
元素是設為 Nodeset,請確認 <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
錯誤訊息
無法透過 Edge UI 或 Edge Management 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.
在失敗的規則運算式保護政策 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 的部署失敗。
解析度
確認規則運算式保護政策中 <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
錯誤訊息
無法透過 Edge UI 或 Edge Management 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.
錯誤螢幕截圖示例
原因
如果 regexProtection 政策不含任何元素 <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>
由於「擷取變數」政策中沒有任何必要元素,因此 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
錯誤訊息
無法透過 Edge UI 或 Edge Management 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 Proxy 部署就會失敗。
診斷
找出發生錯誤的 RegularExpressionProtection 政策名稱,以及沒有
<Pattern>
元素的子項元素。您可以在錯誤訊息中找到這兩個項目。舉例來說,在下列錯誤中,政策名稱為
Regular-Expression-Protection-1
,子元素為XPath:
RegularExpressionProtection Regular-Expression-Protection-1: No patterns to enforce in XPath.
- 檢查失敗的規則運算式防護政策,確認步驟 #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 政策。
如要修正上述範例,我們可以直接將 <Pattern>
元素新增至 <XMLPayload>
下方的 <XPath>
元素:
<?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
錯誤訊息
無法透過 Edge UI 或 Edge Management 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 的前置字串名稱。您可以在錯誤訊息中找到這兩個項目。
舉例來說,在下列錯誤中,政策名稱為「規則運算式保護-1」,前置字串為「apigee」:
RegularExpressionProtection Regular-Expression-Protection-1: Non-empty prefix apigee cannot be mapped to empty uri.
在失敗的規則運算式防護政策 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 中識別的特定前置字串的
<Namespace>
元素是否具備有效的 URI。如果缺少 URI,就是導致錯誤的原因。在上述的規則運算式保護政策範例中,請注意,沒有任何 URI 與
<Namespace>
元素相對應的 URI,字串為 apigee。因此,您會收到錯誤: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
錯誤訊息
無法透過 Edge UI 或 Edge Management 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 政策,以及前置字串的名稱。您可以在錯誤訊息中找到這兩個項目。
舉例來說,在下列錯誤中,政策名稱為「規則運算式保護-1」,前置字串為「apigee」:
RegularExpressionProtection Regular-Expression-Protection-1: Duplicate prefix apigee.
在失敗的規則運算式防護政策 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>
判斷步驟 2 中識別的
<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
錯誤訊息
無法透過 Edge UI 或 Edge Management 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.
在失敗的規則運算式保護政策 XML 中,判斷以下何者的
<XMLPayload>
元素未定義<XPath>
子元素,或者<Expression>
元素未設為任何值。<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
錯誤訊息
無法透過 Edge UI 或 Edge Management 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.
在失敗的規則運算式保護政策 XML 中,判斷以下何者的
<JSONPayload>
元素未定義<JSONPath>
子元素,或者<Expression>
元素未設為任何值。<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>