解碼 JWT 政策部署錯誤

您正在查看 ApigeeApigee Hybrid 說明文件。
查看 Apigee Edge 說明文件。

InvalidEmptyElement

錯誤訊息

透過 Apigee UI 或 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 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>