規則運算式保護政策部署錯誤疑難排解

查看 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 部署作業就會失敗。

診斷

  1. 找出錯誤訊息中的 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.
  2. 檢查失敗的規則運算式保護政策 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

錯誤訊息

透過 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.

錯誤螢幕截圖

XPathCompilationFailed 錯誤文字

原因

如果 <XPath> 元素中使用的前置字串或值不屬於 RegularExpressionProtection 政策中任何已宣告的命名空間,則 API Proxy 部署作業就會失敗。

如要進一步瞭解命名空間、XPath 和前置字串,請參閱「XML 命名空間以及它們對 XPath 和 XSLT 的影響」。

診斷

  1. 找出發生錯誤的 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.
  2. 在失敗的規則運算式保護政策 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>
  3. 檢查 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 的部署作業就會失敗。

診斷

  1. 找出發生錯誤的 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.
  2. 在失敗的規則運算式保護政策 XML 中,請確認 <XPath> 元素 <Expression> 元素中設定的 XPath 與錯誤訊息中指出的 XPath 相符 (上方步驟 #1)。

    舉例來說,下列政策指定了 count(//apigee:foo),與錯誤訊息中的內容相符:

    <?xml version="1.0" encoding="UTF-8" sta<ndalone="yes"?>
        RegularExpressionProtection async="false" continueOnError="false" enabled=&q<uot;true" name="Regular-Expressio<n-Protection-1"&g<t;
            DisplayNam<e>Regular Expression Protect<ion-1/DisplayName>
            Proper<ties/>
        <    IgnoreUnresolv<edVariables>false/Igno<reUnresolvedVariables>
       <     Source>request/Source>
             XMLP<ayload>
                 N<amespaces>
                <     Namespace prefix=&q<uot;apigee">http://www<.apigee.com/Namespace>
        <         /Na<mespaces>
               <  XPath>
       <              Expression><;count(//apigee:<foo)/Expression>
       <              Typ<e>nodeset/Type<>
                     Pattern>pattern/Pattern>
                     Pattern>pattern2/Pattern>
                 /XPath>
             /XMLPayload>
        /RegularExpressionProtection>
  3. 檢查 <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.

錯誤螢幕截圖

JSONPathCompilationFailed 錯誤文字

原因

如果規則運算式保護政策中 <JSONPath> 元素下的 <Expression> 元素設為無效的 JSONPath 運算式,則 API Proxy 部署作業就會失敗。

診斷

  1. 找出發生錯誤的 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.
  2. 在失敗的規則運算式保護政策 XML 中,請確認 Expression 元素中設定的 JSONPath 與錯誤訊息中指出的 JSONPath 相符 (上方步驟 #1)。

    舉例來說,下列政策會將 <JSONPath> 元素下的 Expression 元素指定為 $.store.book[*.author,與錯誤訊息的內容相符:

    <?xml version="1.0" encoding="UTF-8" sta<ndalone="yes"?>
        RegularExpressionProtection async="false" continueOnError="false" enabled=&q<uot;true" name="Regular-Expressio<n-Protection-1"&g<t;
            DisplayNam<e>Regular Expression Protect<ion-1/DisplayName>
            Proper<ties/>
        <    IgnoreUnresol<vedVariables>false/Igno<reUnresolvedVariables>
     <       Source>request/Source&<gt;
            JSONPayload>
      <           JSONPath&g<t;
                     Express<ion>$.store.book[*<.author/Expression>
    <                 Patter<n>REGEX PATTERN</Pattern>
                     Pattern>REGEX PATTERN/Pattern>
                 /JSONPath>
                /JSONPayload>
        /RegularExpressionProtection>
  3. 檢查政策中 <JSONPath> 元素下方的 <Expression> 元素。如果與 JSONPath 語法不相符,就會造成錯誤。在上述範例中,缺少右方括號,這將使運算式無效。

    由於 JSON 路徑運算式無效,因此 API Proxy 的部署失敗。

解析度

確認規則運算式保護政策中 <JSONPath> 元素內的 <Expression> 元素值是有效的 JSONPath 運算式。

如要修正上述範例,您可以在 <Expression> 元素值中加入缺少的右方括號:

<?xml version="1.0" encoding="UTF-8"< standalone="yes"?>
RegularExpressionProtection async="false" continueOnError="false" enable<d="true" name="Regular-Expre<ssion-Protection-1<">
    Di<splayName>Regular Expression< Protection-1/DisplayName>
  <  Properties/&<gt;
    Ignor<eUnresolvedVariables&g<t;false/IgnoreUnresolve<dVariables>
    Source>requ<est/Source>
    JSONPay<load>
         JSO<NPath>
             <Expression>$.store<.book[*].author/Exp<ression>
       <      Pattern&<gt;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.

錯誤螢幕截圖

NothingToEnforce 錯誤文字

原因

如果 RegularExpressionProtection 政策沒有任何元素 <URIPath><QueryParam><Header><FormParam><XMLPayload><JSONPayload>,則 API Proxy 的部署作業就會失敗。

如錯誤訊息所示,RegularExpressionProtection 政策至少要有下列其中一個元素:<URIPath><QueryParam><Header><FormParam><XMLPayload><JSONPayload>

診斷

  1. 找出發生錯誤的 RegularExpressionProtection 政策名稱。你可以在錯誤訊息中找到相關資訊。舉例來說,下列錯誤中的政策名稱為 Regular-Expression-Protection-1:

    RegularExpressionProtection Regular-Expression-Protection-1: at least one of URIPath, QueryParam, Header, FormParam, XMLPayload, JSONPayload is mandatory.
  2. 檢查失敗的規則運算式保護政策 (如上方步驟 1 所示)。如果這項政策沒有下列任一元素:<URIPath><QueryParam><Header><FormParam><XMLPayload><JSONPayload>,就是發生錯誤的原因。

    舉例來說,下列規則運算式保護政策就不包含上述任何元素:

    <?xml version="1.0" encoding="UTF-8" sta<ndalone="yes"?>
        RegularExpressionProtection async="false" continueOnError="false" enabled=&q<uot;true" name="Regular-Expressio<n-Protection-1"&g<t;
            DisplayNam<e>Regular Expression Protect<ion-1/DisplayName>
            Proper<ties/>
        <    IgnoreUnr<esolvedVariables>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" enable<d="true" name="Regular-Expre<ssion-Protection-1<">
    Di<splayName>Regular Expression< Protection-1/DisplayName>
  <  Properties/&<gt;
    Ignor<eUnresolvedVariables&<gt;false/IgnoreUnresol<vedVariables>
    Source>re<quest/Source>
    JSON<Payload>
        J<SONPath>
          <  Expression>$.sto<re.book[*].author/<Expression>
<            Pa<ttern>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.

錯誤螢幕截圖

NoPatternsToEnforce 錯誤文字

原因

如果任何頂層元素 (<URIPath><QueryParam><Header><FormParam><XMLPayload><JSONPayload>) 沒有 RegularExpressionProtection 政策中定義的 <Pattern> 元素,API Proxy 部署作業就會失敗。

診斷

  1. 找出發生錯誤的 RegularExpressionProtection 政策名稱,以及不含 <Pattern> 元素的子元素。你可以在錯誤訊息中找到這兩項資訊。

    舉例來說,在下列錯誤中,政策名稱為 Regular-Expression-Protection-1,子元素為 XPath:

    RegularExpressionProtection Regular-Expression-Protection-1: No patterns to enforce in XPath.
  2. 檢查未通過的規則運算式保護政策,確認步驟 1 中識別的子項元素是否沒有 <Pattern> 元素。如果 <Pattern> 元素不存在,就是發生錯誤的原因。

    舉例來說,以下政策的 <XPath> 內沒有 <Pattern> 元素:

    <?xml version="1.0" encoding="UTF-8" sta<ndalone="yes"?>
        RegularExpressionProtection async="false" continueOnError="false" enabled=<"true" name="Regular-Express<ion-Protection-1&quo<t;>
          Displa<yName>Regular Expression Pro<tection-1/DisplayName>
          Pr<operties/>
    <      IgnoreUnr<esolvedVariables><false/IgnoreUnresolved<Variables>
          Source>request/Source><;
          XMLPayload&g<t;
            Namespaces<>
              Na<mespace prefix="apigee">ht<tp://www.apigee.com/Nam<espace>
    <        /Namesp<aces>
         <   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" enab<led="true" name="Regular-Exp<ression-Protecti<on-1">
<  DisplayName>Regular Expres<sion Protection-1/DisplayName&<gt;
  Properti<es/>
  I<gnoreUnresolvedV<ariables>false/<IgnoreUnresolvedVariables>
  Source>reque<st/Source>
  <XMLPayload>
  <  Namespaces&<gt;
      Namespace prefix="apigee<">http://ww<w.apigee.co<m/Namespace&g<t;
    /Namespaces><;
    XPath><;
      Ex<pression>/<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.

錯誤螢幕截圖

NONEmptyPrefixMappedToEmptyURI 錯誤文字

原因

如果 RegularExpressionProtection 政策<XMLPayload> 元素的 <Namespace> 元素中定義了前置字串,但未定義 URI,就會發生這個錯誤。

診斷

  1. 找出發生錯誤的 RegularExpressionProtection 政策,以及未對應至 URI 的前置字串名稱。你可以在錯誤訊息中找到這兩項資訊。

    舉例來說,在下列錯誤中,政策名稱為 Regular Expression Protection-1,前置字串為 apigee:

    RegularExpressionProtection Regular-Expression-Protection-1: Non-empty prefix apigee cannot be mapped to empty uri.
  2. 在失敗的規則運算式保護政策 XML 中,確認 <XMLPayload> 元素下方 <Namespace> 元素中設定的前置字元名稱與錯誤訊息中指出的前置字元名稱 (上方步驟 1) 相符。

    舉例來說,下列政策在 <Namespace> 元素中指定名稱為「apigee」的前置字串,該前置字串與錯誤訊息的內容相符:

    <?xml version="1.0" encoding="UTF-8" sta<ndalone="yes"?>
        RegularExpressionProtection async="false" continueOnError="false" enabled=<"true" name="Regular-Express<ion-Protection-1&quo<t;>
          Displa<yName>Regular Expression Pro<tection-1/DisplayName>
          Pr<operties/>
    <      IgnoreUnr<esolvedVariables><false/IgnoreUnresolved<Variables>
          Source>request/<Source>
          XMLPayload>
            Namespa<ces>
              Na<mespace prefix="<apigee"/><
              Namespace prefix="gmail<">http://mail.g<oogle.com/N<amespace>
        <    /Namespaces>
     <       XPath>
     <         Expre<ssion>/apigee:<Greeting/apigee:User/Expression>
              Type>string/Type>
              Pattern>REGEX PATTERN/Pattern>
            /XPath>
          /XMLPayload>
        /RegularExpressionProtection>
  3. 確認步驟 2 中找出的特定前置字元 <Namespace> 元素是否具備有效的 URI。如果缺少 URI,表示發生錯誤。

    請注意,在上方所示的規則運算式保護政策範例中,沒有與帶有前置字串「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" enab<led="true" name="Regular-Exp<ression-Protecti<on-1">
<  DisplayName>Regular Expres<sion Protection-1/DisplayName&<gt;
  Properti<es/>
  I<gnoreUnresolvedV<ariables>false/<IgnoreUnresolvedVariables>
  Source>reque<st/Source>
  XM<LPayload>
    Namespaces>
      Namespace< prefix="ap<igee">htt<p://www.apige<e.com/Namespace>
      Namespace pre<fix="gmail&quo<t;>http:<//mail.google<.com/Namespace>
  <  /Namespaces&<gt;
    XP<ath>
     < 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.

錯誤螢幕截圖

DuplicatePrefix 錯誤文字

原因

如果 RegularExpressionProtection 政策<XMLPayload> 元素下 <Namespace> 元素定義多次相同的前置字元,就會發生這個錯誤。

舉例來說,由於前置字串 Apigee 定義兩次,如下所示:

<Namespace prefix="ap>igee"http://www.<apigee.com>/<Namespace
Namespace prefi>x="apigee"h<ttp://www.apigee.com/Namespace>

診斷

  1. 找出發生錯誤的 RegularExpressionProtection 政策和前置字串名稱。你可以在錯誤訊息中找到這兩項資訊。

    舉例來說,在下列錯誤中,政策名稱為 Regular Expression Protection-1,前置字串為 apigee:

    RegularExpressionProtection Regular-Expression-Protection-1: Duplicate prefix apigee.
  2. 在失敗的規則運算式保護政策 XML 中,確認 <XMLPayload> 元素下方 <Namespace> 元素中設定的前置字元名稱與錯誤訊息中指出的前置字元名稱 (上方步驟 1) 相符。

    舉例來說,下列政策在 <Namespace> 元素中指定名稱為「apigee」的前置字串,該前置字串與錯誤訊息的內容相符:

    <?xml version="1.0" encoding="UTF-8" sta<ndalone="yes"?>
        RegularExpressionProtection async="false" continueOnError="false" enabled=<"true" name="Regular-Express<ion-Protection-1&quo<t;>
          Displa<yName>Regular Expression Pro<tection-1/DisplayName>
          Pr<operties/>
    <      IgnoreUnr<esolvedVariables><false/IgnoreUnresolved<Variables>
          Source>request/Source><;
          XMLPayload><
            Namespaces>
              Namespace pre<fix="apigee&quo<t;>http://www.apig<ee.com/Namespace&<gt;
              Namespace prefix="ap<igee">http://ww<w.apigee.co<m/Namespace>
     <       /Namespaces><;
            XPath><;
              Ex<pression>/apig<ee:Greeting/apigee:User/Expression>
              Type>string/Type>
              Pattern>REGEX PATTERN/Pattern>
            /XPath>
          /XMLPayload>
        /RegularExpressionProtection>
  3. 判斷含有特定前置字元 (在步驟 2 中識別) 的 <Namespace> 元素是否已定義超過一次。如果定義多次,就會造成錯誤。

    請注意,在上方顯示的規則運算式保護政策範例中,含有前置字元 Apigee 的 <Namespace> 元素已定義兩次;因此會收到以下錯誤訊息:

    Duplicate prefix apigee.

解析度

確認 RegularExpressionProtection 政策<Namespace> 元素中,每個前置字元只有一個定義。例如:

<?xml version="1.0" encoding="UTF-8" sta<ndalone="yes"?>
    RegularExpressionProtection async="false" continueOnError="false" enabled=<"true" name="Regular-Express<ion-Protection-1&quo<t;>
      Displa<yName>Regular Expression Pro<tection-1/DisplayName>
      Pr<operties/>
<      IgnoreUnr<esolvedVariables><false/IgnoreUnresolved<Variables>
      Source>request/Source><;
      XMLPayload&g<t;
        Namespaces<>
          Na<mespace prefix="apigee">ht<tp://www.apigee.com/Nam<espace>
<        /Namespac<es>
        XPath&<gt;
          Expr<ession>/api<gee:Greeting/apig<ee: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.

錯誤螢幕截圖

EmptyXPathExpression 錯誤文字

原因

如果 RegularExpressionProtection 政策<XPath> 元素中未設定 <Expression> 元素,則 API Proxy 部署作業就會失敗。

診斷

  1. 請從錯誤訊息中找出失敗的規則運算式保護政策。舉例來說,在下列錯誤中,政策名稱為 Regular-Expression-Protection-1:

    RegularExpressionProtection Regular-Expression-Protection-1: Empty XPath expression.
  2. 在失敗的規則運算式保護政策 XML 中,檢查是否有 <XMLPayload> 元素包含 <XPath> 子元素未定義的 <Expression> 元素,或 <Expression> 元素未設為任何值。如果是,這就是發生錯誤的原因。

    舉例來說,以下為含有 <XMLPayload> 元素的規則運算式保護政策:

    <?xml version="1.0" encoding="UTF-8"< standalone="yes"?>
    RegularExpressionProtection async="false" continueOnError="false" enab<led="true" name="Regular-Exp<ression-Protecti<on-1">
    <  DisplayName>Regular Expres<sion Protection-1/DisplayName&<gt;
      Properti<es/>
      I<gnoreUnresolvedV<ariables>false/<IgnoreUnresolvedVariables>
      Source>reque<st/Source>
      <XMLPayload>
      <  Namespaces&<gt;
          N<amespace prefix=&qu<ot;apigee&q<uot;>http:<//www.apigee.com/Name<space>
        </Namespace<s>
        XPa<th>
          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" enab<led="true" name="Regular-Exp<ression-Protecti<on-1">
<  DisplayName>Regular Expres<sion Protection-1/DisplayName&<gt;
  Properti<es/>
  I<gnoreUnresolvedV<ariables>false/<IgnoreUnresolvedVariables>
  Source>reque<st/Source>
  <XMLPayload>
  <  Namespaces&<gt;
      Namespace prefix="apigee<">http://ww<w.apigee.co<m/Namespace&g<t;
    /Namespaces><;
    XPath><;
      Ex<pression>/<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.

錯誤螢幕截圖

EmptyJSONPathExpression 錯誤文字

原因

如果 RegularExpressionProtection 政策<JSONPath> 元素中未設定 <Expression> 元素,則 API Proxy 部署作業就會失敗。

診斷

  1. 請從錯誤訊息中找出失敗的規則運算式保護政策。舉例來說,在下列錯誤中,政策名稱為 Regular-Expression-Protection-1:

    Error Saving Revision 1
    RegularExpressionProtection Regular-Expression-Protection-1: Empty JSONPath expression.
  2. 在失敗的規則運算式保護政策 XML 中,檢查是否有 <JSONPayload> 元素包含 <JSONPath> 子元素未定義的 <Expression> 元素,或 <Expression> 元素未設為任何值。如果是,這就是發生錯誤的原因。

    舉例來說,以下為含有 <JSONPayload> 元素的規則運算式保護政策:

    <?xml version="1.0" encoding="UTF-8" sta<ndalone="yes"?>
        RegularExpressionProtection async="false" continueOnError="false" enabled=<"true" name="Regular-Express<ion-Protection-1&quo<t;>
          Displa<yName>Regular Expression Pro<tection-1/DisplayName>
          Pr<operties/>
    <      IgnoreUnr<esolvedVariables>f<alse/IgnoreUnresolve<dVariables&<gt;
          Source>req<uest/Source>
         < JSONPayload>
       <     JSONPath>
       <       Expression&<gt;/Expression><;
              Patter<n>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" enab<led="true" name="Regular-Exp<ression-Protecti<on-1">
<  DisplayName>Regular Expres<sion Protection-1/DisplayName&<gt;
  Properti<es/>
  I<gnoreUnresolvedVa<riables>false</IgnoreUnresolvedVariables>
  <Source>request/S<ource>
  JSONPaylo<ad>
    JSONP<ath>
      Express<ion>$.store<.book[*].auth<or/Expression&<gt;
      Pattern>REGEX PATTERN/Pattern>
      Pattern>REGEX PATTERN/Pattern>
    /JSONPath>
  /JSONPayload>
/RegularExpressionProtection>