Khắc phục sự cố triển khai chính sách Bảo vệ biểu thức chính quy

Bạn đang xem tài liệu về Apigee Edge.
Chuyển đến tài liệu về Apigee X.
thông tin

InvalidRegularExpression

Thông báo lỗi

Không triển khai được proxy API thông qua giao diện người dùng Edge hoặc API quản lý Edge với thông báo lỗi sau:

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.

Thông báo lỗi mẫu

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.

Ảnh chụp màn hình lỗi ví dụ

Văn bản lỗi InvalidĐược phép hợp lệ

Nguyên nhân

Nếu biểu thức chính quy trong phần tử <Pattern> của chính sáchRegularExpressionProtection không hợp lệ, thì việc triển khai Proxy API sẽ không thành công.

Chẩn đoán

  1. Xác định tên của RegularExpressionProtection trong thông báo lỗi. Ví dụ: trong lỗi sau, tên RegularExpressionProtectionRegular-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. Kiểm tra tất cả các phần tử <Pattern> trong XML chính sách Bảo vệ biểu thức chính quy không thành công. Kiểm tra xem có phần tử <Pattern> nào có biểu thức chính quy không hợp lệ hay không. Nếu bất kỳ phần tử <Pattern> nào có biểu thức chính quy không hợp lệ, thì đó là nguyên nhân gây ra lỗi.

    Ví dụ: chính sách sau đây chỉ định giá trị Pattern> của foo){2}, được coi là Biểu thức chính quy không hợp lệ:

    <?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>
    

    Trong ví dụ trên, biểu thức chính quy được chỉ định trong <Pattern> bị thiếu dấu ngoặc đơn mở. Do đó, biểu thức này được coi là biểu thức chính quy không hợp lệ. Do đó, bạn không thể triển khai Proxy API.

Độ phân giải

Đảm bảo rằng mỗi phần tử <Pattern> trong RegularExpressionProtection đều chứa một biểu thức chính quy hợp lệ. Bạn có thể tìm kiếm nhiều công cụ biểu thức chính quy trực tuyến hoặc ngoại tuyến để gỡ lỗi biểu thức chính quy. Để sửa chính sách Bảo vệ biểu thức chính quy mẫu nêu trên, hãy thêm dấu ngoặc đơn còn thiếu:

<?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

Thông báo lỗi

Không triển khai được proxy API thông qua giao diện người dùng Edge hoặc API quản lý Edge với thông báo lỗi sau:

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.

Thông báo lỗi mẫu

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.

Ảnh chụp màn hình lỗi ví dụ

Văn bản lỗi XPathCompilationFailed

Nguyên nhân

Nếu tiền tố hoặc giá trị dùng trong phần tử <XPath> không thuộc bất kỳ không gian tên nào đã khai báo trong RegularExpressionProtection, thì sẽ không triển khai được proxy API.

Bạn có thể tìm thêm thông tin về không gian tên, XPath và tiền tố trong phần Không gian tên XML và Cách chúng ảnh hưởng đến XPath và GCC.

Chẩn đoán

  1. Xác định tên của chính sách RegularExpressionProtection nơi xảy ra lỗi và Biểu thức XPath được sử dụng. Bạn có thể tìm thấy cả hai mục này trong thông báo lỗi.

    Ví dụ: trong lỗi sau, tên chính sách là Regular-Expression-Protection-1 và Biểu thức XPath là /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. Trong XML chính sách Bảo vệ biểu thức chính quy không thành công, xác minh rằng XPath được đặt trong phần tử Expression khớp với XPath được xác định trong thông báo lỗi (bước #1 ở trên).

    Ví dụ: chính sách sau đây chỉ định XPath là /notapigee:foo/notapigee:bar khớp với nội dung trong thông báo lỗi:

    <?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. Kiểm tra các phần tử <Namespaces><Expression> trong chính sáchRegularExpressionProtection. Nếu <Expression> cụ thể được chỉ ra trong thông báo lỗi sử dụng một tiền tố hoặc giá trị không thuộc vùng chứa tên được khai báo trong RegularExpressionProtection, thì đó chính là nguyên nhân gây ra lỗi.

    Xin lưu ý rằng <XPath> cụ thể này sử dụng tiền tố notapigee trong ví dụ về RegularExpressionProtection chính sách:

    <Expression>/notapigee:foo/notapigee:bar</Expression>

    Tuy nhiên, tiền tố notapigee không được định nghĩa trong bất kỳ phần tử <Namespace> nào; do đó, việc biên dịch <XPath> không thành công dẫn đến lỗi triển khai.

Độ phân giải

Hãy đảm bảo tất cả không gian tên đang được dùng trong các phần tử <Expression> của các phần tử <XPath> đều được khai báo trong chính sáchRegularExpressionProtection. Để khắc phục ví dụ trên, bạn có thể thay thế tiền tố notapigee thành apigee (được khai báo trong vùng chứa tên):

<?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

Thông báo lỗi

Không triển khai được proxy API thông qua giao diện người dùng Edge hoặc API quản lý Edge với thông báo lỗi sau:

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.

Thông báo lỗi mẫu

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.

Ảnh chụp màn hình lỗi ví dụ

Văn bản lỗi Không thể chuyển đổiToNodeset

Nguyên nhân

Nếu Chính sách biểu thức chính quy có một biểu thức <XPath>, trong đó phần tử <Type> được định nghĩa là tập nút, nhưng không thể chuyển đổi biểu thức này thành tập hợp nút, thì việc triển khai proxy API sẽ không thành công.

Chẩn đoán

  1. Xác định chính sách ChromeOSionProtection nơi xảy ra lỗi và Biểu thức XPath không thể chuyển đổi thành tập hợp nút. Bạn có thể tìm thấy cả hai mục này trong thông báo lỗi.

    Ví dụ: trong lỗi sau, tên chính sách là Regular-Expression-Protection-1 và Biểu thức XPath là 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. Trong XML chính sách Bảo vệ biểu thức chính quy không thành công, hãy xác minh rằng XPath được đặt trong phần tử <Expression> của phần tử <XPath> khớp với XPath được xác định trong thông báo lỗi (bước #1 ở trên).

    Ví dụ: chính sách sau đây chỉ định là count(//apigee:foo), khớp với nội dung trong thông báo lỗi:

    <?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>
    
  3. Kiểm tra giá trị được đặt trong phần tử <Type> bên dưới phần tử <XPath>. Nếu phần tử <Type>nodeset, thì đó là nguyên nhân gây ra lỗi.

    Trong ví dụ này, biểu thức XPath là count() không trả về một hoặc nhiều nút. Do đó, không thể triển khai Proxy API.

Độ phân giải

Nếu phần tử <Type> được đặt thành tập hợp nút, hãy đảm bảo rằng kết quả của phần tử <Expression> được đặt trong <XPath> là một hoặc nhiều nút. Ngoài ra, hãy thay đổi phần tử <Type> thành một giá trị phù hợp hơn dựa trên trường hợp sử dụng của bạn.

Để sửa ví dụ trên, bạn có thể thay đổi phần tử <Expression> thành một giá trị khác có thể trả về các nút:

<?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

Thông báo lỗi

Không triển khai được proxy API thông qua giao diện người dùng Edge hoặc API quản lý Edge với thông báo lỗi sau:

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.

Thông báo lỗi mẫu

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.

Ảnh chụp màn hình lỗi ví dụ

Văn bản lỗi JSONPathCompilationFailed

Nguyên nhân

Nếu bạn đặt phần tử <Expression> trong phần tử <JSONPath> của chính sách Bảo vệ biểu thức chính quy thành biểu thức JSONPath không hợp lệ, thì sẽ không triển khai được proxy API.

Chẩn đoán

  1. Xác định tên của chính sách RegularExpressionProtection nơi xảy ra lỗi và biểu thức JSONPath không hợp lệ được sử dụng. Bạn có thể tìm thấy cả hai mục này trong thông báo lỗi.

    Ví dụ: trong lỗi sau, tên chính sách là Regular-Expression-Protection-1 và Biểu thức JSONPath là $.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. Trong XML chính sách Bảo vệ biểu thức chính quy không thành công, hãy xác minh rằng JSONPath được đặt trong phần tử Expression khớp với JSONPath đã xác định trong thông báo lỗi (bước #1 ở trên).

    Ví dụ: chính sách sau đây chỉ định phần tử Expression trong <JSONPath>$.store.book[*.author, khớp với nội dung trong thông báo lỗi:

    <?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>
    
  3. Hãy kiểm tra phần tử <Expression> trong phần tử <JSONPath> của chính sách. Nếu mã này không khớp với cú pháp JSONPath thì đây là nguyên nhân gây ra lỗi. Trong ví dụ trên, thiếu dấu ngoặc vuông đóng, điều này khiến biểu thức không hợp lệ.

    Vì Biểu thức đường dẫn JSON không hợp lệ nên không thể triển khai Proxy API.

Độ phân giải

Đảm bảo rằng giá trị cho phần tử <Expression> bên trong phần tử <JSONPath> trong chính sách Bảo vệ biểu thức chính quy là một biểu thức JSONPath hợp lệ.

Để sửa ví dụ ở trên, bạn có thể thêm dấu ngoặc vuông đóng còn thiếu vào giá trị phần tử <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

Thông báo lỗi

Không triển khai được proxy API thông qua giao diện người dùng Edge hoặc API quản lý Edge với thông báo lỗi sau:

Error Saving Revision revision_number
RegularExpressionProtection policy_name: at least one of URIPath, QueryParam, Header, FormParam, XMLPayload, JSONPayload is mandatory.

Thông báo lỗi mẫu

Error Saving Revision 1
RegularExpressionProtection Regular-Expression-Protection-1: at least one of URIPath, QueryParam, Header, FormParam, XMLPayload, JSONPayload is mandatory.

Ảnh chụp màn hình lỗi ví dụ

Văn bản lỗi NothingToEnforce

Nguyên nhân

Nếu chính sách ChromeOSionProtection không có phần tử nào trong số các phần tử <URIPath>, <QueryParam>, <Header>, <FormParam>, <XMLPayload> hoặc <JSONPayload>, thì có nghĩa là không thể triển khai Proxy API.

Như đã nêu trong thông báo lỗi, chính sáchRegularExpressionProtection phải có ít nhất một trong các phần tử sau đây được đưa vào chính sách: <URIPath>, <QueryParam>, <Header>, <FormParam>, <XMLPayload> hoặc <JSONPayload>.

Chẩn đoán

  1. Xác định tên của chính sách RegularExpressionProtection gây ra lỗi. Bạn có thể tìm thấy mã này trong thông báo lỗi. Ví dụ: trong lỗi sau, chính sách có tên là Regular-Expression-Protection-1:

    RegularExpressionProtection Regular-Expression-Protection-1: at least one of URIPath, QueryParam, Header, FormParam, XMLPayload, JSONPayload is mandatory.
    
  2. Kiểm tra chính sách Bảo vệ biểu thức chính quy không thành công (đã xác định trong bước #1 ở trên). Nếu chính sách không có một trong các phần tử sau đây: <URIPath>, <QueryParam>, <Header>, <FormParam>, <XMLPayload> hoặc <JSONPayload>, thì đó chính là nguyên nhân gây ra lỗi.

    Ví dụ: chính sách Bảo vệ biểu thức chính quy sau đây không có bất kỳ thành phần nào được đề cập ở trên:

    <?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>
    

    Vì không có phần tử bắt buộc nào trong chính sách Trích xuất biến, nên không triển khai được proxy API.

Độ phân giải

Hãy đảm bảo rằng chính sáchRegularExpressionProtection có ít nhất một trong các phần tử bắt buộc sau đây: <URIPath>, <QueryParam>, <Header>, <FormParam>, <XMLPayload> hoặc <JSONPayload>. Ví dụ:

<?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

Thông báo lỗi

Không triển khai được proxy API thông qua giao diện người dùng Edge hoặc API quản lý Edge với thông báo lỗi sau:

Error Saving Revision revision_number
RegularExpressionProtection policy_name: No patterns to enforce in payload_name.

Thông báo lỗi mẫu

Error Saving Revision 1
RegularExpressionProtection Regular-Expression-Protection-1: No patterns to enforce in XPath.

Ảnh chụp màn hình lỗi ví dụ

Văn bản lỗi NoPatternsToEnforce

Nguyên nhân

Nếu bất cứ phần tử cấp cao nhất nào (<URIPath>, <QueryParam>, <Header>, <FormParam>, <XMLPayload> hoặc <JSONPayload>) không có phần tử <Pattern> được xác định trong RegularExpressionProtection, thì tức là không triển khai được proxy API.

Chẩn đoán

  1. Xác định tên của chính sách RegularExpressionProtection nơi xảy ra lỗi và phần tử con không có phần tử <Pattern>. Bạn có thể tìm thấy cả hai mục này trong thông báo lỗi.

    Ví dụ: trong lỗi sau đây, chính sách có tên là Regular-Expression-Protection-1 và phần tử con là XPath:

    RegularExpressionProtection Regular-Expression-Protection-1: No patterns to enforce in XPath.
    
  2. Kiểm tra chính sách Bảo vệ biểu thức chính quy không đạt và xác minh xem phần tử con đã xác định trong bước #1 không có phần tử <Pattern> hay không. Nếu phần tử <Pattern> không tồn tại trong đó, thì đó là nguyên nhân gây ra lỗi.

    Ví dụ: chính sách sau đây không có phần tử <Pattern> bên trong <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>
            </XPath>
          </XMLPayload>
        </RegularExpressionProtection>
    

    Vì phần tử <XPath> không có phần tử <Pattern> nên không triển khai được Proxy API.

Độ phân giải

Đảm bảo rằng mọi phần tử <URIPath>, <QueryParam>, <Header>, <FormParam>, <XMLPayload> hoặc <JSONPayload> đều có ít nhất một <Pattern> được chỉ định. Hãy xem chính sách RegularExpressionProtection để biết thông tin về cách chỉ định phần tử một cách chính xác.

Để khắc phục ví dụ ở trên, chúng ta chỉ cần thêm phần tử <Pattern> vào phần tử <XPath> bên dưới <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>/apigee:Greeting/apigee:User</Expression>
      <Type>string</Type>
      <Pattern>REGEX PATTERN</Pattern>
    </XPath>
  </XMLPayload>
</RegularExpressionProtection>

NONEmptyPrefixMappedToEmptyURI

Thông báo lỗi

Không triển khai được proxy API thông qua giao diện người dùng Edge hoặc API quản lý Edge với thông báo lỗi sau:

Error Saving Revision revision_number
RegularExpressionProtection policy_name: Non-empty prefix prefix_name cannot be mapped to empty uri.

Thông báo lỗi mẫu

Error Saving Revision 1
RegularExpressionProtection Regular-Expression-Protection-1: Non-empty prefix apigee cannot be mapped to empty uri.

Ảnh chụp màn hình lỗi ví dụ

Văn bản lỗi NONEmptyPrefixMappedToEmptyURI

Nguyên nhân

Lỗi này xảy ra nếu chính sách ChromeOSionProtection có một tiền tố được xác định trong phần tử <Namespace> của phần tử <XMLPayload> nhưng không xác định được URI nào.

Chẩn đoán

  1. Xác định chính sáchRegularExpressionProtection nơi xảy ra lỗi và tên của tiền tố không được liên kết với URI. Bạn có thể tìm thấy cả hai mục này trong thông báo lỗi.

    Ví dụ: trong lỗi sau, tên chính sách là Bảo vệ biểu thức chính quy-1 và tiền tố là apigee:

    RegularExpressionProtection Regular-Expression-Protection-1: Non-empty prefix apigee cannot be mapped to empty uri.
    
  2. Trong XML chính sách Bảo vệ biểu thức chính quy không thành công, hãy xác minh rằng tên của tiền tố được đặt trong phần tử <Namespace> của phần tử <XMLPayload> khớp với tên tiền tố được xác định trong thông báo lỗi (bước #1 ở trên).

    Ví dụ: Chính sách sau đây chỉ định một tiền tố có tên apigee trong phần tử <Namespace> khớp với nội dung trong thông báo lỗi:

    <?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>
    
  3. Xác thực xem phần tử <Namespace> có tiền tố cụ thể được xác định ở bước 2 có URI hợp lệ hay không. Nếu thiếu URI, thì đó là nguyên nhân gây ra lỗi.

    Trong ví dụ về Chính sách bảo vệ biểu thức chính quy nêu trên, hãy lưu ý rằng không có URI nào tương ứng với phần tử <Namespace> có tiền tố apigee; do đó, bạn sẽ gặp lỗi:

    Non-empty prefix apigee cannot be mapped to empty uri.

Độ phân giải

Đảm bảo rằng tất cả phần tử <Namespace> được xác định bằng một tiền tố đều có URI tương ứng trong chính sách Trích xuất biến. Ví dụ:

<?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

Thông báo lỗi

Không triển khai được proxy API thông qua giao diện người dùng Edge hoặc API quản lý Edge với thông báo lỗi sau:

Error Saving Revision revision_number
RegularExpressionProtection policy_name: Duplicate prefix prefix_name.

Thông báo lỗi mẫu

Error Saving Revision 1
RegularExpressionProtection Regular-Expression-Protection-1: Duplicate prefix apigee.

Ảnh chụp màn hình lỗi ví dụ

Văn bản lỗi DuplicatePrefix

Nguyên nhân

Lỗi này xảy ra nếu chính sách RegularExpressionProtection có cùng một tiền tố được xác định nhiều lần trong phần tử <Namespace> của phần tử <XMLPayload>.

Ví dụ: lỗi này xảy ra vì tiền tố apigee được xác định hai lần như minh hoạ dưới đây:

<Namespace prefix="apigee">http://www.apigee.com</Namespace>
<Namespace prefix="apigee">http://www.apigee.com</Namespace>

Chẩn đoán

  1. Xác định chính sách RegularExpressionProtection nơi xảy ra lỗi và tên của tiền tố. Bạn có thể tìm thấy cả hai mục này trong thông báo lỗi.

    Ví dụ: trong lỗi sau, tên chính sách là Bảo vệ biểu thức chính quy-1 và tiền tố là apigee:

    RegularExpressionProtection Regular-Expression-Protection-1: Duplicate prefix apigee.
    
  2. Trong XML chính sách Bảo vệ biểu thức chính quy không thành công, hãy xác minh rằng tên của tiền tố được đặt trong phần tử <Namespace> của phần tử <XMLPayload> khớp với tên tiền tố được xác định trong thông báo lỗi (bước #1 ở trên).

    Ví dụ: Chính sách sau đây chỉ định một tiền tố có tên apigee trong phần tử <Namespace> khớp với nội dung trong thông báo lỗi:

    <?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>
    
  3. Xác định xem phần tử <Namespace> có tiền tố cụ thể (xác định ở bước 2) có được xác định nhiều lần hay không. Nếu thông số được xác định nhiều lần thì đó là nguyên nhân gây ra lỗi.

    Trong ví dụ về Chính sách bảo vệ biểu thức chính quy ở trên, hãy lưu ý rằng phần tử <Namespace> có tiền tố apigee đã được xác định hai lần; do đó, bạn sẽ gặp lỗi:

    Duplicate prefix apigee.
    

Độ phân giải

Đảm bảo rằng chỉ có một định nghĩa cho mỗi tiền tố trong các phần tử <Namespace> trong RegularExpressionProtection. Ví dụ:

<?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

Thông báo lỗi

Không triển khai được proxy API thông qua giao diện người dùng Edge hoặc API quản lý Edge với thông báo lỗi sau:

Error Saving Revision revision_number
RegularExpressionProtection policy_name: Empty XPath expression.

Thông báo lỗi mẫu

Error Saving Revision 1
RegularExpressionProtection Regular-Expression-Protection-1: Empty XPath expression.

Ảnh chụp màn hình lỗi ví dụ

Văn bản lỗi EmptyXPathbiểu thức này

Nguyên nhân

Nếu chính sáchRegularExpressionProtection không có phần tử <Expression> nào được đặt trong phần tử <XPath>, thì tức là không triển khai được proxy API.

Chẩn đoán

  1. Xác định chính sách Bảo vệ biểu thức chính quy không thành công từ thông báo lỗi. Ví dụ: trong lỗi sau, tên chính sách là Regular-Expression-Protection-1:

    RegularExpressionProtection Regular-Expression-Protection-1: Empty XPath expression.
    
  2. Trong XML chính sách Bảo vệ biểu thức chính quy không thành công, hãy xác định xem có phần tử <XMLPayload> có phần tử con <XPath> mà chưa xác định phần tử <Expression> nào hoặc phần tử <Expression> chưa được đặt thành bất kỳ giá trị nào. Nếu có thì đó chính là nguyên nhân gây ra lỗi.

    Ví dụ: sau đây là chính sách Bảo vệ biểu thức chính quy có phần tử <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>
    

    Vì có một phần tử <Expression> trống trong phần tử <XPath>, nên không thể triển khai Proxy API.

Độ phân giải

Đảm bảo rằng chính sáchRegularExpressionProtection có phần tử <Expression> không trống và hợp lệ được xác định trong phần tử <XPath>. Ví dụ:

<?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

Thông báo lỗi

Không triển khai được proxy API thông qua giao diện người dùng Edge hoặc API quản lý Edge với thông báo lỗi sau:

Error Saving Revision revision_number
RegularExpressionProtection policy_name: Empty JSONPath expression.

Thông báo lỗi mẫu

Error Saving Revision 1
RegularExpressionProtection Regular-Expression-Protection-1: Empty JSONPath expression.

Ảnh chụp màn hình lỗi ví dụ

Văn bản lỗi EmptyJSONPathExpression

Nguyên nhân

Nếu chính sáchRegularExpressionProtection không có phần tử <Expression> nào được đặt trong phần tử <JSONPath>, thì tức là không triển khai được proxy API.

Chẩn đoán

  1. Xác định chính sách Bảo vệ biểu thức chính quy không thành công từ thông báo lỗi. Ví dụ: trong lỗi sau, tên chính sách là Regular-Expression-Protection-1:

    Error Saving Revision 1
    RegularExpressionProtection Regular-Expression-Protection-1: Empty JSONPath expression.
    
  2. Trong XML chính sách Bảo vệ biểu thức chính quy không thành công, hãy xác định xem có phần tử <JSONPayload> có phần tử con <JSONPath> mà chưa xác định phần tử <Expression> nào hay không, hoặc phần tử <Expression> chưa được đặt thành giá trị nào. Nếu có thì đó chính là nguyên nhân gây ra lỗi.

    Ví dụ: sau đây là chính sách Bảo vệ biểu thức chính quy có phần tử <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>
    

    Vì có một phần tử <Expression> trống trong phần tử <JSONPath>, nên không thể triển khai Proxy API.

Độ phân giải

Đảm bảo rằng chính sáchRegularExpressionProtection có phần tử <Expression> không trống và hợp lệ được xác định trong phần tử <JSONPath>. Ví dụ:

<?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>