DecodeJWT 政策部署错误问题排查

您正在查看的是 Apigee Edge 文档。
转到 Apigee X 文档
信息

InvalidEmptyElement

错误消息

通过 Edge 界面或 Edge Management API 部署 API 代理失败,并显示以下错误消息:

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

错误消息示例

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

示例屏幕截图

在 Edge 界面中,您将看到一个显示错误消息的对话框:

原因

如果未在 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>