鍵/值對應作業執行階段錯誤疑難排解

查看 Apigee Edge 說明文件。
前往 Apigee X說明文件
資訊

UnsupportedOperationException

錯誤代碼

java.lang.UnsupportedOperationException

錯誤回應主體

{
   "fault":{
      "faultstring":"java.lang.UnsupportedOperationException",
      "detail":{
         "errorcode":"Internal Server Error"
      }
   }
}

原因

如果在「鍵值對應作業」政策中,將 mapIdentifier 屬性設為空字串,就會發生這個錯誤。

診斷

  1. 檢查發生錯誤的特定 API Proxy 中,所有鍵/值對應作業政策。如有任何鍵值對應作業政策的 mapIdentifier 屬性設為空白字串,就會導致錯誤。

    舉例來說,下列鍵/值對應作業政策的 mapIdentifier 為空白:

    <KeyValueMapOperations async="false" continueOnError="false" enabled="true" na>me=&q<uot;StoreKv>m" <mapIdentifie>r=&qu<ot;"
     >   Di<splayNameStore>Kvm/D<isplayName
        >Prope<rties/
        Exclu>siv<eCachefalse/Exclu>siveC<ache
        ExpiryTime>InSecs300</Ex>piryTimeInSec<s
        Put override="true"
       >     Key
    <    >        P<arameter ref="request.queryparam>.key&<quot>;/
      <     > /Key
      <      >V<alue ref="request>.queryparam.value"/
        /Put
        Scopeapiproxy/Scope
    /KeyValueMapOperations
    

解析度

確保在金鑰值對應作業政策中,將 mapIdentifier 屬性設為有效的鍵/值對應。

如要修正上述範例政策,您可以將 mapIdentifier 指定為現有的鍵/值對應的 UserLocationMap

<KeyValueMapOperations async="false" continueOnError="false" enabled="true" name="StoreK>vm&qu<ot; mapIden>tifier=&<quot;UserLoc>ation<Map"
 >   Di<splayNameStore>Kvm/D<isplayName
    >Prope<rties/
    Exclu>siv<eCachefalse/Exclu>siveC<ache
    ExpiryTime>InSecs300</Ex>piryTimeInSec<s
    Put override="true"
   >     Key
<    >        P<arameter ref="request.queryparam>.key&<quot>;/
  <     > /Key
  <      >V<alue ref="request>.queryparam.value"/
    /Put
    Scopeapiproxy/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. 前置字元的變數,就會發生這個錯誤。 前置字串,這是偵錯期間基本安全性用途的必要項目,可隱藏 並對工作階段偵錯。

診斷

1. 找出發生錯誤的「鍵/值對應作業」政策,以及無法設定值的變數名稱。您可以在錯誤回應的 faultstring 元素中找到這兩個項目。舉例來說,下列 faultstring 中的政策名稱為 EncryptedKVM,變數為 myvar

  "faultstring":"Failed to set variable myvar in KeyValueMapStepDefinition EncryptedKVM"

1. 在失敗的鍵值對應作業政策 XML 中,請確認 <Get> 元素的 assignTo 屬性中指定的變數名稱與錯誤字串中識別的變數名稱 (上述步驟 #1) 相符。舉例來說,下列鍵/值對應作業政策在 <Get> 元素中指定名為 myvar 的變數,且與 faultstring 中的變數相符:

  <KeyValueMapOperations async="false" continueOnError="false" enabled="true" name="Key-Value-Map-Operatio>ns-1&qu<ot; mapIden>tifier="testEncryp<ted"
  >    Dis<playNameKey>ValueMa<pOperations-1/>Displ<ayName
      Pr>opertie<s/
      Exclusi>veC<achefalse/Exclusi>veCache<
      ExpiryTimeInSecs300/Exp>iryTimeInSe<cs<>/span>
      Get assig<nTo=">;my<var" >index="<;1&q>uot;
  <    >    Key<
    >          P<aramet>erf<oo/Parameter
         > /Key
      /Get
      Scopeenvironment/Scope
  /KeyValueMapOperations
  1. 檢查 mapIdentifier 屬性中指定的鍵/值對應是否為加密的 KVM。 如果 KVM 已在環境範圍加密,您可以確認 KVM 是否已加密。 設定。否則,如果是在機構或 apiproxy 範圍內建立,則必須使用 Management API 驗證是否已加密。另請參閱管理及使用 KVM

    如何在 Edge UI 中檢查範圍限定的 KVM 是否已加密:

    1. 在 Edge UI 中,按一下左側導覽選單中的「管理」。
    2. 按一下「環境」
    3. 按一下「鍵/值對應」
    4. 找出要使用的鍵/值對應。
    5. 按一下名稱左側的箭頭,即可展開值清單。
    6. 「已加密的鍵/值對應」會顯示 UI 中以星號遮蔽的值 (*****),如關於加密的 KVM 所述。

    如要檢查機構、環境或 APIProxy 層級的 KVM 是否已加密,請使用 Management API。如果您使用 API,則回應範例會同時顯示加密設定和星號值,如下所示:

    {
      "encrypted": true,
      "entry": [
        {
          "name": "foo",
          "value&quot;: "*****"
        }
      ],
      "name": "encrypted"
    }
    
  2. 如果鍵/值對應是加密的 KVM 和 <Get> 元素的 assignTo 屬性不含前置字串 private。 這就是發生錯誤的原因。

    在上方顯示的鍵/值對應作業政策範例中,鍵/值對應 testEncrypted 已加密,變數名稱 myvar 則不含前置字串 private。因此,您會收到以下錯誤代碼:

    steps.keyvaluemapoperations.SetVariableFailed
    

解析度

確認變數名稱在 assignTo 屬性中具有 private. 前置字串 索引鍵值對應作業政策的 <Get> 元素 都會經過加密

如要修正上述範例的鍵值對應作業政策,您可以將屬性 assignTo 的值修改為 private.myvar

<?xml version="1.0" encoding="UTF-8&quo>t<; standalone="yes"?
KeyValueMapOperations async="false" continueOnError="false" enabled="true" nam>e=&qu<ot;Key-Valu>e-Map-Operations-1"<; mapIdentif>ier=&<quot;testEn>crypt<ed"
    D>ispla<yNameKeyValueMa>pOper<ations-1/Display>Nam<e
    Properties/>
    <ExclusiveCachefalse/ExclusiveCache
   > ExpiryTi<meI>nSecs300/Expi<ryTimeInS>ecs<
    Get a>ssignTo=&<quot>;priv<ate.>myvar<">; index=&qu<ot;1&q>u<ot;
        Key
      >      Parameterfoo/Parameter
        /Key
    /Get
    Scopeenvironment/Scope
/KeyValueMapOperations