解碼 JWT 政策部署錯誤

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

InvalidEmptyElement

錯誤訊息

無法透過 Edge UI 或 Edge Management 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).

螢幕截圖範例

在 Edge UI 中,您會看到出現錯誤的對話方塊:

原因

如果 DecodeJWT 政策的 <Source> 元素中未指定包含要解碼的 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>