您正在查看 Apigee 和 Apigee Hybrid 說明文件。
查看
Apigee Edge 說明文件。
UnsupportedOperationException
錯誤代碼
java.lang.UnsupportedOperationException
錯誤回應主體
{
"fault":{
"faultstring":"java.lang.UnsupportedOperationException",
"detail":{
"errorcode":"Internal Server Error"
}
}
}
原因
如果在「鍵值對應作業」政策中,將 mapIdentifier
屬性設為空字串,就會發生這個錯誤。
診斷
檢查發生失敗的特定 API Proxy 中,所有 Key Value Map Operations 政策。如果任何鍵值對應作業政策的
mapIdentifier
屬性設為空字串,就會導致錯誤。舉例來說,下列「鍵/值對應作業」政策有空白的
mapIdentifier
:<KeyValueMapOperations async="false" continueOnError="false" enabled="true" name="StoreKvm" mapIdentifier=""> <DisplayName>StoreKvm</DisplayName> <Properties/> <ExclusiveCache>false</ExclusiveCache> <ExpiryTimeInSecs>300</ExpiryTimeInSecs> <Put override="true"> <Key> <Parameter ref="request.queryparam.key"/> </Key> <Value ref="request.queryparam.value"/> </Put> <Scope>environment</Scope> </KeyValueMapOperations>
解決方法
確認屬性 mapIdentifier
已設為有效的鍵/值對應,並套用至「鍵/值對應作業」政策。
如要修正上述政策範例,您可以將 mapIdentifier
指定為現有的鍵值對應項目 UserLocationMap
。
<KeyValueMapOperations async="false" continueOnError="false" enabled="true" name="StoreKvm" mapIdentifier="UserLocationMap">
<DisplayName>StoreKvm</DisplayName>
<Properties/>
<ExclusiveCache>false</ExclusiveCache>
<ExpiryTimeInSecs>300</ExpiryTimeInSecs>
<Put override="true">
<Key>
<Parameter ref="request.queryparam.key"/>
</Key>
<Value ref="request.queryparam.value"/>
</Put>
<Scope>environment</Scope>
</KeyValueMapOperations>
SetVariableFailed
錯誤代碼
steps.keyvaluemapoperations.SetVariableFailed
錯誤回應主體
{ "fault":{ "faultstring":"Failed to set variable variable_name in KeyValueMapStepDefinition policy_name", "detail":{ "errorcode":"steps.keyvaluemapoperations.SetVariableFailed" } } }
錯誤訊息範例
{
"fault":{
"faultstring":"Failed to set variable myvar in KeyValueMapStepDefinition EncryptedKVM",
"detail":{
"errorcode":"steps.keyvaluemapoperations.SetVariableFailed"
}
}
}
原因
如果您嘗試從加密的鍵值對應中擷取值,並將該值設為名稱中沒有 private.
前置字元的變數,就會發生這個錯誤。前置字串是偵錯期間的基本安全性需求,可隱藏 API 代理追蹤和偵錯工作階段中的加密值。
診斷
1.
找出發生錯誤的「Key-Value 對應作業」政策,以及無法設定值的變數名稱。您可以在錯誤回應的 faultstring
元素中找到這兩項項目。例如,在以下 faultstring
中,政策名稱為 EncryptedKVM
,變數為 myvar
:
"faultstring":"Failed to set variable myvar in KeyValueMapStepDefinition EncryptedKVM"
1.
在失敗的 Key Value Map Operations 政策 XML 中,請確認 <Get>
元素的 assignTo
屬性中指定的變數名稱,與錯誤字串中指出的變數名稱相符 (上方步驟 1)。舉例來說,下列 Key Value Map 運算政策會在 <Get>
元素中指定名為 myvar
的變數,與 faultstring
中的變數相符:
<KeyValueMapOperations async="false" continueOnError="false" enabled="true" name="Key-Value-Map-Operations-1" mapIdentifier="testEncrypted">
<DisplayName>KeyValueMapOperations-1</DisplayName>
<Properties/>
<ExclusiveCache>false</ExclusiveCache>
<ExpiryTimeInSecs>300</ExpiryTimeInSecs>
<Get assignTo="myvar" index="1">
<Key>
<Parameter>foo</Parameter>
</Key>
</Get>
<Scope>environment</Scope>
</KeyValueMapOperations>
檢查
mapIdentifier
屬性中指定的鍵/值對應是否為加密的 KVM。如何檢查 Apigee UI 中是否已對 KVM 進行加密:
- 在 Apigee UI 中,按一下左側導覽選單中的「管理」。
- 按一下「環境」。
- 按一下「鍵/值對應」。
- 找出要使用的鍵/值對應。
- 按一下名稱左側的箭頭,展開值清單。
- 加密鍵值對應會在 UI 中以星號遮蓋值 (*****),如「關於加密 KVM」一文所示。
如果鍵/值對應是加密的 KVM,且
<Get>
元素的assignTo
屬性中使用的變數名稱沒有前置字元private
。那就是錯誤的原因。在上述範例的鍵/值對應作業政策中,鍵/值對應
testEncrypted
已加密,且變數名稱myvar
沒有前置字串private
。因此,您會收到以下錯誤代碼:steps.keyvaluemapoperations.SetVariableFailed
解決方法
如果使用的值對應作業政策中的 <Get>
元素 assignTo
屬性中變數名稱含有前置字串 private.
,請務必確保該變數名稱已加密。
如要修正上述範例的「鍵值對應作業」政策,您可以將屬性 assignTo
的值修改為 private.myvar
:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<KeyValueMapOperations async="false" continueOnError="false" enabled="true" name="Key-Value-Map-Operations-1" mapIdentifier="testEncrypted">
<DisplayName>KeyValueMapOperations-1</DisplayName>
<Properties/>
<ExclusiveCache>false</ExclusiveCache>
<ExpiryTimeInSecs>300</ExpiryTimeInSecs>
<Get assignTo="private.myvar" index="1">
<Key>
<Parameter>foo</Parameter>
</Key>
</Get>
<Scope>environment</Scope>
</KeyValueMapOperations>