解碼 JWT 政策部署錯誤

您目前查看的是 ApigeeApigee Hybrid 說明文件。
查看 Apigee Edge 說明文件。

InvalidEmptyElement

錯誤訊息

透過 Apigee 使用者介面或 API 部署 API Proxy 時失敗,並顯示以下錯誤訊息:

Error Saving Revision
Invalid empty element : policy(policy_name) element(Source)

錯誤訊息示例

Error Saving Revision
Invalid empty element : policy(Decode_JWT) element(Source).

螢幕截圖範例

Apigee 使用者介面會顯示含有錯誤的對話方塊:

儲存修訂版本時發生錯誤。

原因

如果要在 DecodeJWT 政策的 <Source> 元素中指定要解碼的 JWT,但含有該 JWT 的流程變數未指定,就會發生這項錯誤。

舉例來說,如果 <Source> 元素不含值,就會發生錯誤,如下所示:

<Source></Source>

診斷

  1. 從錯誤訊息中找出 DecodeJWT 政策的名稱,以及空白元素的名稱。舉例來說,在下列錯誤訊息中,DecodeJWT 政策的名稱為 Decode_JWT,元素名稱為 Source

    Invalid empty element : policy(Decode_JWT) element(Source).
  2. 檢查 DecodeJWT 政策,確認步驟 1 中識別的元素是否為空白。如果元素為空白,就是導致錯誤的原因。

    以下是 DecodeJWT 政策範例:

    <DecodeJWT name="Decode_JWT">
        <DisplayName>JWT Decode HS256</DisplayName>
        <Source></Source>
        <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
    </DecodeJWT>
    

    由於 <Source> 元素空白,因此您會收到下列錯誤訊息:

    Invalid empty element : policy(Decode_JWT) element(Source).
    

解析度

確認 <Source> 元素在流程變數中指定有效的 JWT。

如要修正範例 DecodeJWT 政策的問題,您可以在 <Source> 元素中指定含有有效 JWT 的流程變數。

<DecodeJWT name="Decode_JWT">
    <DisplayName>JWT Decode HS256</DisplayName>
    <Source>var.jwt</Source>
    <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
</DecodeJWT>