排解鍵/值對應作業政策部署錯誤

您正在查看 Apigee Edge 說明文件。
查看 Apigee X 說明文件
資訊

InvalidIndex

錯誤訊息

無法透過 Edge UI 或 Edge Management API 部署 API Proxy,並顯示以下錯誤訊息:

Error Saving Revision revision_number
Invalid index index in KeyValueMapStepDefinition policy_name.

錯誤訊息範例

Error Saving Revision 2
Invalid index 0 in KeyValueMapStepDefinition GetKVM.

錯誤螢幕截圖示例

原因

如果在鍵值對應作業政策的 <Get> 元素中指定的 index 屬性為零或負數,API Proxy 部署就會失敗。索引從 1 開始,因此系統會將零或負整數的索引視為無效。

舉例來說,如果鍵值對應作業政策的 <Get> 元素中指定 index0,API Proxy 的部署就會失敗。

診斷

  1. 找出發生錯誤的鍵/值對應作業政策和無效的索引。您可以在錯誤訊息中找到這項資訊。舉例來說,在下列錯誤中,政策名稱為 GetKVM,無效的索引則為 0

    Invalid index 0 in KeyValueMapStepDefinition GetKVM.

  2. 驗證失敗的鍵/值對應作業政策的 <Get> 元素中指定的索引值,與錯誤訊息中指出的值 (請見上方的步驟 #1) 相符。例如,下列政策會將索引值指定為 0,此值與錯誤訊息中的內容相符:

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <KeyValueMapOperations mapIdentifier="FooKVM" async="false" continueOnError="false" enabled="true" name="GetKVM">
        <DisplayName>GetKVM</DisplayName>
        <ExpiryTimeInSecs>86400</ExpiryTimeInSecs>
        <Scope>environment</Scope>
        <Get assignTo="foo_variable" index="0">
            <Key>
                <Parameter>FooKey_1</Parameter>
            </Key>
        </Get>
    </KeyValueMapOperations>
    
  3. 如果指定的索引為零或負整數,就是發生錯誤的原因。

    在上述範例的鍵/值對應作業政策中,索引的值為 0,這是無效的。因此,API Proxy 的部署失敗並顯示以下錯誤:

    Invalid index 0 in KeyValueMapStepDefinition GetKVM.
    

解析度

確保鍵值對應作業政策的 <Get> 元素中指定的索引屬性有效 (非零或負整數)。

如要修正上述範例鍵/值對應作業政策,您可以將索引修改為 1

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<KeyValueMapOperations mapIdentifier="FooKVM" async="false" continueOnError="false" enabled="true" name="GetKVM">
    <DisplayName>GetKVM</DisplayName>
    <ExpiryTimeInSecs>86400</ExpiryTimeInSecs>
    <Scope>environment</Scope>
    <Get assignTo="foo_variable" index="1">
        <Key>
            <Parameter>FooKey_1</Parameter>
        </Key>
    </Get>
</KeyValueMapOperations>

KeyIsMissing

錯誤訊息

無法透過 Edge UI 或 Edge Management API 部署 API Proxy,並顯示以下錯誤訊息:

Error Saving Revision revision_number
Error occurred while validation of bean policy_name.xml
Reason: - Non null value expected for element Parameter in Entry.

錯誤訊息範例

Error Saving Revision 3
Error occurred while validation of bean GetKVM.xml. Reason: - Non null value expected for element Parameter in Entry

錯誤螢幕截圖示例

原因

如果金鑰值對應作業政策的 <Entry> 元素中缺少 <Key> 元素,或缺少 <Parameter> 元素,就會發生這個錯誤。<Key><InitialEntries>

診斷

  1. 找出發生錯誤的鍵/值對應作業政策。您可以在錯誤訊息中找到這項資訊。舉例來說,在下列錯誤中,鍵/值對應作業政策的名稱為 GetKVM

    Error occurred while validation of bean GetKVM.xml. Reason: - Non null value expected for element Parameter in Entry
    
  2. 在失敗的鍵/值對應作業政策中,檢查 <InitialEntries> 下方是否有任何 <Entry> 元素缺少 <Key><Parameter> 元素。

    以下是鍵/值對應作業政策的範例,在 <Key> 元素中缺少 <Parameter> 元素:

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <KeyValueMapOperations async="false" continueOnError="false" enabled="true" name="GetKVM" mapIdentifier="FooKVM">
        <DisplayName>GetKVM</DisplayName>
        <Properties/>
        <ExclusiveCache>false</ExclusiveCache>
        <ExpiryTimeInSecs>300</ExpiryTimeInSecs>
        <InitialEntries>
            <Entry>
                <Key/>
                <Value>v1</Value>
            </Entry>
            <Entry>
                <Key>
                    <Parameter>k2</Parameter>
                </Key>
                <Value>v2</Value>
            </Entry>
        </InitialEntries>
    

    在這種情況下,問題出在第一個元素。

解析度

確認鍵/值對應作業政策中 <InitialEntries> 元素下方的所有 <Entry> 元素,都有 <Key> 元素和 <Parameter> 元素。

如要修正上述範例鍵/值對應作業政策,加入 <Parameter> 元素即可解決問題:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<KeyValueMapOperations async="false" continueOnError="false" enabled="true" name="GetKVM" mapIdentifier="FooKVM">
    <DisplayName>GetKVM</DisplayName>
    <Properties/>
    <ExclusiveCache>false</ExclusiveCache>
    <ExpiryTimeInSecs>300</ExpiryTimeInSecs>
    <InitialEntries>
        <Entry>
            <Key>
                <Parameter>k1</Parameter>
            </Key>
            <Value>v1</Value>
        </Entry>
        <Entry>
            <Key>
                <Parameter>k2</Parameter>
            </Key>
            <Value>v2</Value>
        </Entry>
    </InitialEntries>
    ...

ValueIsMissing

錯誤訊息

無法透過 Edge UI 或 Edge Management API 部署 API Proxy,並顯示以下錯誤訊息:

Error Saving Revision revision_number
Error occurred while validation of bean policy_name.xml. Reason: - Non null value expected for element Value in Entry.

錯誤訊息範例

Error Saving Revision 3
Error occurred while validation of bean GetKVM.xml.Reason: - Non null value expected for element Value in Entry

錯誤螢幕截圖示例

原因

在鍵/值對應作業政策的 <InitialEntries> 元素的 <Entry> 元素下方,缺少 <Value> 元素,就會發生這個錯誤。

診斷

  1. 找出發生錯誤的鍵/值對應作業政策。您可以在錯誤訊息中找到這項資訊。舉例來說,在下列錯誤中,鍵/值對應作業政策的名稱為 GetKVM

    Error occurred while validation of bean GetKVM.xml. Reason: - Non null value expected for element Value in Entry
    
  2. 在失敗的鍵/值對應作業政策中,檢查 <InitialEntries> 下方是否有任何 <Entry> 元素缺少 <Value> 元素。

    以下是缺少 <Value> 元素的「鍵/值對應作業」政策範例:

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <KeyValueMapOperations async="false" continueOnError="false" enabled="true" name="GetKVM" mapIdentifier="testNotEncrypte">
        <DisplayName>GetKVM3</DisplayName>
        <Properties/>
        <ExclusiveCache>false</ExclusiveCache>
        <ExpiryTimeInSecs>300</ExpiryTimeInSecs>
        <InitialEntries>
            <Entry>
                <Key>
                    <Parameter>k1</Parameter>
                </Key>
            </Entry>
            <Entry>
                <Key>
                    <Parameter>k2</Parameter>
                </Key>
                <Value>v2</Value>
            </Entry>
        </InitialEntries>
        ...
    
    

解析度

在鍵/值對應作業政策中,確認 <InitialEntries> 元素下方的所有 <Entry> 元素都含有 <Value> 元素。

如要修正上述範例鍵/值對應作業政策,加入 <Value> 元素即可解決問題:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<KeyValueMapOperations async="false" continueOnError="false" enabled="true" name="GetKVM" mapIdentifier="testNotEncrypte">
    <DisplayName>GetKVM3</DisplayName>
    <Properties/>
    <ExclusiveCache>false</ExclusiveCache>
    <ExpiryTimeInSecs>300</ExpiryTimeInSecs>
    <InitialEntries>
        <Entry>
            <Key>
                <Parameter>k1</Parameter>
            </Key>
            <Value>v1</Value>
        </Entry>
        <Entry>
            <Key>
                <Parameter>k2</Parameter>
            </Key>
            <Value>v2</Value>
        </Entry>
    </InitialEntries>
    ...