键值对映射操作政策部署错误问题排查

您正在查看的是 Apigee Edge 文档。
转到 Apigee X 文档
信息

InvalidIndex

错误消息

通过 Edge 界面或 Edge Management API 部署 API 代理失败,并显示以下错误消息:

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 代理的部署将失败。索引从 1 开始,因此零或负整数的索引被视为无效。

例如,如果所指定的 index 为键值最映射操作政策的 <Get> 元素中的 0,则 API 代理的部署将失败。

诊断

  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 代理的部署失败并显示以下错误:

    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 界面或 Edge Management API 部署 API 代理失败,并显示以下错误消息:

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

错误屏幕截图示例

原因

如果在键值对映射操作政策的 <InitialEntries> 元素的 <Entry> 下的 <Key> 元素内完全没有 <Key> 元素或缺少 <Parameter> 元素,就会出现此错误。

诊断

  1. 找出出错的键值对映射操作政策。您可以从错误消息中找到此信息。 例如,在下面的错误中,键值对映射操作政策的名称为 GetKVM

    Error occurred while validation of bean GetKVM.xml. Reason: - Non null value expected for element Parameter in Entry
    
  2. 在失败的键值对映射操作政策中,查看是否有任何 <Entry> 元素在 <InitialEntries> 下缺少 <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 界面或 Edge Management API 部署 API 代理失败,并显示以下错误消息:

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. 在失败的键值对映射操作政策中,查看是否有任何 <Entry> 元素在 <InitialEntries> 元素下缺少 <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>
    ...