# 错误码
调用接口出错后，将不会返回结果数据。调用方可根据每个接口对应的错误码来定位错误原因。当调用出错时，HTTP 请求返回一个4xx或5xx的HTTP状态码。返回的消息体中是具体的错误代码及错误信息。在调用方找不到错误原因时，可以联系华为云客服，并提供错误码，以便我们尽快帮您解决问题。
#### 错误响应Body体格式说明
当接口调用出错时，会返回错误码及错误信息说明，错误响应的Body体格式如下所示。
```
{
    "error_code": "AgentIdentity.0027",
    "error_msg": "workload identity already exists",
    "request_id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}
```
其中，error_code表示错误码，error_msg表示错误描述信息，request_id表示本次请求的ID。
特别地，如果是因为缺少权限而出错时，错误相应的Body体格式如下所示。
```
{
    "error_code": "AgentIdentity.0027",
    "error_msg": "workload identity already exists",
    "request_id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    "encoded_authorization_message": "xxx...xxx"
}
```
其中，encoded_authorization_message为该场景下额外提供的字段，表示加密后的认证失败信息，可以通过STS5解密接口进行解密。
#### 错误码说明
当您调用API时，如果遇到"APIGW"开头的错误码，请参见[API网关错误码](https://support.huaweicloud.com/devg-apisign/api-sign-errorcode.html)进行处理。
表1错误码 
| 状态码  | 错误码                                 | 错误信息                                                                                                                                  | 描述                                                      | 处理措施                                           |
|:---|:---|:---|:---|:---|
| 403  | AgentIdentity.0001                   | access denied: {0}                                                                                                                     | 访问被拒绝: {0}                                             | 请检查用户是否有对应资源的操作权限                            |
| 400      | AgentIdentity.0002                 | missing header x-user-profile                                                                                                        | 缺少请求头 x-user-profile                                   | 请确认请求头中包含 x-user-profile                        |
| 400    | AgentIdentity.0007                    | invalid marker                                                                                                                           | 无效的分页标记                                                | 请检查分页参数 marker 是否合法                         |
| 400  | AgentIdentity.0031                   | invalid agency urn                                                                                                                    | 无效的 agency URN                                            | 请检查 agency URN 格式是否正确                        |
| 400   | AgentIdentity.0032                    | duplicate key for: {0}                                                                                                                 | 重复键: {0}                                                | 请确保键值唯一，不重复                                    |
| 400   | AgentIdentity.0054                  | tag limit exceeded                                                                                                                    | 标签数量超限                                                   | 请减少标签数量                                        |
| 400    | AgentIdentity.0056                  | tag policy violation                                                                                                                  | 标签策略违规                                                  | 请检查标签是否符合标签策略要求                               |
| 400   | AgentIdentity.0057                | policy validation failed                                                                                                               | 策略验证失败                                                   | 请检查策略语法是否正确                                    |
| 404    | AgentIdentity.0034                  | no such resource                                                                                                                       | 资源不存在                                                   | 请确认资源 ID 是否正确                                 |
| 429  | AgentIdentity.0053                   | too many requests, please retry later                                                                                                   | 请求过多，请稍后重试                                             | 请稍后重试                                          |
| 400    | AgentIdentity.0003                  | the credential provider vendor not supported                                                                                            | 不支持该凭据提供者厂商                                            | 请确认凭证提供商类型是否支持                                |
| 404    | AgentIdentity.0004                   | no such credential provider                                                                                                            | 凭据提供者不存在                                                | 请确认凭证提供商名称是否正确                                 |
| 409   | AgentIdentity.0005                   | credential provider already exists                                                                                                      | 凭据提供者已存在                                                  | 请更换名称或使用已有凭证提供商                              |
| 400      | AgentIdentity.0049                       | oauth2 credential provider quota exceeded                                                                                              | OAuth2 凭据提供者配额超限                                      | 请申请提升配额或删除不用的凭证提供商                            |
| 400     | AgentIdentity.0050                     | api key credential provider quota exceeded                                                                                              | API Key 凭据提供者配额超限                                       | 请申请提升配额或删除不用的凭证提供商                             |
| 400    | AgentIdentity.0051                  | sts credential provider quota exceeded                                                                                                 | STS 凭据提供者配额超限                                            | 请申请提升配额或删除不用的凭证提供商                             |
| 400     | AgentIdentity.0006                 | invalid OIDC configuration                                                                                                               | 无效的 OIDC 配置                                             | 请检查 OIDC 配置参数是否正确                             |
| 400    | AgentIdentity.0008                    | invalid URL and must end with '/.well-known/openid-configuration'                                                                        | 无效的 URL，必须以 /.well-known/openid-configuration 结尾        | 请确保 URL 以 /.well-known/openid-configuration 结尾 |
| 400     | AgentIdentity.0009                    | HTTPS protocol required for {0}                                                                                                         | {0} 需要 HTTPS 协议                                         | 请确保使用 HTTPS 协议                                 |
| 400     | AgentIdentity.0010                  | invalid OIDC metadata                                                                                                                  | 无效的 OIDC 元数据                                             | 请检查 OIDC 元数据格式是否正确                             |
| 400     | AgentIdentity.0011                   | Well-Known endpoint unreachable                                                                                                          | Well-Known 端点不可达                                        | 请确认端点地址可访问且网络连通                                 |
| 400    | AgentIdentity.0012                    | JWKS endpoint unreachable                                                                                                              | JWKS 端点不可达                                                | 请确认 JWKS 端点地址可访问且网络连通                        |
| 400    | AgentIdentity.0013                    | JWKS keys array is empty                                                                                                                | JWKS keys 数组为空                                          | 请确认 JWKS 端点返回的密钥数组非空                           |
| 400   | AgentIdentity.0014                   | invalid jwks format                                                                                                                    | 无效的 JWKS 格式                                              | 请检查 JWKS 格式是否符合标准                             |
| 400      | AgentIdentity.0015                   | authorization_endpoint is required                                                                                                    | authorization_endpoint 为必填项                             | 请确认 OIDC 配置中包含 authorization_endpoint           |
| 400     | AgentIdentity.0016                  | id_token_signing_alg_values_supported is required                                                                                     | id_token_signing_alg_values_supported 为必填项               | 请确认 OIDC 配置中包含签名算法列表                          |
| 400      | AgentIdentity.0017                   | id_token_signing_alg_values_supported must include RS256                                                                               | id_token_signing_alg_values_supported 必须包含 RS256        | 请确保签名算法列表包含 RS256                            |
| 400   | AgentIdentity.0020                  | issuer is required                                                                                                                     | issuer 为必填项                                             | 请确认 OIDC 配置中包含 issuer 字段                     |
| 400  | AgentIdentity.0021                   | token_endpoint is required                                                                                                             | token_endpoint 为必填项                                      | 请确认 OIDC 配置中包含 token_endpoint 字段               |
| 404    | AgentIdentity.0022                   | no such token vault                                                                                                                   | Token Vault 不存在                                       | 请确认 Token Vault ID 是否正确                        |
| 404  | AgentIdentity.0023                   | no such workload identity                                                                                                              | 工作负载身份不存在                                              | 请确认工作负载身份名称是否正确                                 |
| 403   | AgentIdentity.0024                  | workloadIdentity is linked to a service and cannot be deleted by the caller                                                          | 工作负载身份已关联服务，调用方无权删除                                     | 请确认该工作负载身份未被服务关联                              |
| 409    | AgentIdentity.0027                    | workload identity already exists                                                                                                     | 工作负载身份已存在                                               | 请更换名称或使用已有工作负载身份                              |
| 400   | AgentIdentity.0048                  | workload identity quota exceeded                                                                                                     | 工作负载身份配额超限                                            | 请申请提升配额或删除不用的工作负载身份                            |
| 400    | AgentIdentity.0025                  | authorizer type does not match authorizer configuration                                                                               | 授权器类型与授权器配置不匹配                                         | 请确认授权者类型与配置一致                                 |
| 400   | AgentIdentity.0026                | invalid custom claims                                                                                                                 | 无效的自定义 claims                                          | 请检查自定义声明格式是否正确                              |
| 409     | AgentIdentity.0028                | authorizer configuration already exists                                                                                              | 授权器配置已存在                                               | 请确认是否已存在授权者配置                                 |
| 404    | AgentIdentity.0030                  | no such authorizer configuration                                                                                                       | 授权器配置不存在                                              | 请确认授权者配置名称是否正确                               |
| 404   | AgentIdentity.0036                  | no such policy engine                                                                                                                  | 策略集不存在                                                 | 请确认策略引擎名称是否正确                                  |
| 409    | AgentIdentity.0037                  | policy engine already exists                                                                                                          | 策略集已存在                                                 | 请更换名称或使用已有策略引擎                                 |
| 409    | AgentIdentity.0038                | policy engine has attachments and cannot be deleted                                                                                   | 策略集存在关联绑定，无法删除                                       | 请先删除关联的附件再删除策略引擎                             |
| 409    | AgentIdentity.0039                 | policy engine contains policies and cannot be deleted                                                                                 | 策略集包含策略，无法删除                                           | 请先删除关联的策略再删除策略引擎                              |
| 400     | AgentIdentity.0041                  | policy engine type mismatch                                                                                                            | 策略集类型不匹配                                                | 请确认策略引擎类型与操作一致                                |
| 400  | AgentIdentity.0042                 | policy engine quota exceeded                                                                                                         | 策略集配额超限                                               | 请申请提升配额或删除不用的策略引擎                             |
| 400     | AgentIdentity.0052                  | total policy size exceeds the policy engine limit                                                                                      | 策略总大小超出策略集限制                                          | 请减小策略总大小或申请提升配额                               |
| 400    | AgentIdentity.0043                   | policy quota exceeded                                                                                                                | 策略配额超限                                                   | 请申请提升配额或删除不用的策略                                |
| 400  | AgentIdentity.0044                  | policy is in a transitional state and cannot be modified                                                                               | 策略处于过渡状态，无法修改                                            | 请稍后重试，等待策略状态稳定                                 |
| 400   | AgentIdentity.0045                  | policy size limit exceeded                                                                                                           | 策略大小超限                                                  | 请减小策略内容大小                                      |
| 404    | AgentIdentity.0046                   | no such policy                                                                                                                          | 策略不存在                                                    | 请确认策略名称是否正确                                     |
| 409     | AgentIdentity.0047                     | policy already exists                                                                                                                | 策略已存在                                                 | 请更换名称或使用已有策略                                  |
| 400 | AgentIdentity.1001                    | bad request                                                                                                                            | 请求无效                                                  | 请检查请求参数是否正确                                   |
| 409   | AgentIdentity.1002                  | concurrent modification                                                                                                                | 并发修改冲突                                                  | 请稍后重试                                        |
| 400     | AgentIdentity.1003                  | CSMS service rate limit exceeded                                                                                                     | CSMS 服务限流                                               | 请稍后重试                                         |
| 400  | AgentIdentity.1004                  | invalid CSMS secret format                                                                                                           | 无效的 CSMS 密钥格式                                         | 请检查密钥格式是否正确                                   |
| 404   | AgentIdentity.1005                  | CSMS secret not found                                                                                                                 | CSMS 密钥不存在                                            | 请确认密钥 ID 是否正确                                |
| 500   | AgentIdentity.1006                 | CSMS service internal error                                                                                                            | CSMS 服务内部错误                                             | 请联系技术支持                                       |
| 400    | AgentIdentity.1007                   | invalid resource id                                                                                                                    | 无效的资源 ID                                               | 请检查资源 ID 格式是否正确                                |
| 429   | AgentIdentityTokenVault.0429        | Too Many Requests                                                                                                                      | 请求过多                                                   | 请降低请求频率，稍后重试                                    |
| 400     | AgentIdentityTokenVault.1001         | Workload Access Token is invalid or expired                                                                                           | Workload Access Token 无效或已过期                            | 请检查并更新 Workload Access Token                     |
| 400  | AgentIdentityTokenVault.1002        | The identity in the request does not match the session identity information                                                           | 请求中的身份与会话身份信息不匹配                                       | 请确保请求中的身份信息与创建会话时一致                          |
| 400    | AgentIdentityTokenVault.1003        | Session workload identity mismatch                                                                                                    | 会话工作负载身份不匹配                                             | 请检查请求的工作负载身份是否正确                               |
| 400   | AgentIdentityTokenVault.1004         | Identity is empty                                                                                                                      | 身份为空                                                   | 请提供有效的身份信息                                      |
| 404    | AgentIdentityTokenVault.1005          | Session not found                                                                                                                      | 会话未找到                                                     | 请检查会话URI是否正确或会话是否已过期                             |
| 400    | AgentIdentityTokenVault.1006          | Failed to get oauth2 token: {0}                                                                                                          | 获取 OAuth2 token 失败                                     | 请检查 OAuth2 配置或联系管理员                          |
| 403   | AgentIdentityTokenVault.1007        | access denied: {0}                                                                                                                    | 访问被拒绝                                                   | 请检查用户是否有对应资源的操作权限                             |
| 400    | AgentIdentityTokenVault.1008         | Invalid resource URN                                                                                                                   | 无效的资源 URN                                              | 请检查资源 URN 格式是否正确                               |
| 400    | AgentIdentityTokenVault.1009         | Conflict: both workload_access_token and security_token are provided                                                                   | 冲突的 token（同时提供了 workload_access_token 和 security_token） | 请只提供一种认证方式                                    |
| 400    | AgentIdentityTokenVault.1010        | Resource oauth2 return url is not in the allowed list for workload identity/resource_oauth2_return_url should not be set for M2M flow | 无效的资源 OAuth2 返回 URL                                    | 请检查 OAuth2 返回 URL 配置                          |
| 400    | AgentIdentityTokenVault.1011        | Workload identity urn is invalid                                                                                                       | 无效的工作负载身份 URN                                         | 请检查工作负载身份 URN 格式                              |
| 400    | AgentIdentityTokenVault.1012         | OAuth2 token has expired                                                                                                               | OAuth2 token 已过期                                       | 请刷新或重新获取 OAuth2 token                          |
| 400     | AgentIdentityTokenVault.1013       | STS5 error message or Assume agency failed                                                                                           | STS5 Assume 失败                                           | 请检查 STS 配置或联系管理员                              |
| 400    | AgentIdentityTokenVault.1014          | Session {0} status is invalid                                                                                                        | 会话状态无效                                                  | 请检查会话状态或重新创建会话                                 |
| 400  | AgentIdentityTokenVault.1015         | User ID and user token cannot both exist                                                                                               | 身份不明确（User ID 和 user token 同时存在）                        | 请只提供一种用户身份标识                                   |
| 400  | AgentIdentityTokenVault.1016        | custom_state is required                                                                                                               | custom_state 是必需的                                         | 请提供 custom_state 参数                              |
| 400    | AgentIdentityTokenVault.1017       | Credential provider ID mismatch                                                                                                       | 凭证提供者 ID 不匹配                                          | 请检查凭证提供者 ID 是否与请求一致                          |
| 400   | AgentIdentityTokenVault.1018       | Invalid request URI format: {0}. Expected format: urn:ietf:params:oauth:request_uri:\[a-zA-Z0-9-._\~\]+ with length between 1 and 1024   | 无效的会话 URI 格式                                            | 请按照指定格式提供 request_uri                          |
| 400     | AgentIdentityTokenVault.1019         | Invalid user token                                                                                                                    | 无效的用户 token                                             | 请检查并更新用户 token                                |
| 400    | AgentIdentityTokenVault.1020         | custom_parameters should not be set for M2M flow                                                                                      | M2M 流程不应设置 custom_parameters                           | 请移除 custom_parameters 参数                        |
| 400    | AgentIdentityTokenVault.1021        | Failed to parse client_credentials token response                                                                                      | 解析 client_credentials token 响应失败                        | 请检查 OAuth2 服务端响应                               |
| 400  | AgentIdentityTokenVault.1022           | Failed to request client_credentials token                                                                                              | 请求 client_credentials token 失败                          | 请检查 OAuth2 配置或联系管理员                          |
| 404    | AgentIdentityTokenVault.1101         | Resource not found: {0}                                                                                                                 | 资源未找到                                                 | 请检查资源名称或 URN 是否正确                               |
| 404    | AgentIdentityTokenVault.1102         | agency with urn {0} cannot be found                                                                                                  | agency 未找到                                               | 请检查 agency URN 是否正确                           |
| 400   | AgentIdentityDirectoryService.2002  | invalid custom claim validation config                                                                                                 | 自定义声明验证配置无效                                              | 请检查 JWT 自定义声明验证配置                             |
| 400 | AgentIdentityDirectoryService.2003  | failed to discover provider metadata                                                                                                 | Provider 元数据发现失败                                      | 请检查 JWT 配置中的 discovery_url 是否可访问             |
| 400  | AgentIdentityDirectoryService.2004   | failed to parse JWT token                                                                                                             | JWT 解析失败                                              | 请检查 user_token 格式是否正确                         |
| 400   | AgentIdentityDirectoryService.2005    | failed to verify JWT claims                                                                                                           | JWT Claims 验证失败                                         | 请检查 JWT 中的声明信息                                |
| 400    | AgentIdentityDirectoryService.2006   | invalid JWT audience                                                                                                                | 无效的 audience                                           | 请检查 JWT 中的 aud 声明                             |
| 400   | AgentIdentityDirectoryService.2007    | invalid JWT client ID                                                                                                                | 无效的 client_id                                           | 请检查 JWT 中的 client_id 声明                       |
| 400    | AgentIdentityDirectoryService.2008 | invalid JWT scope                                                                                                                    | 无效的 scope                                             | 请检查 JWT 中的 scope 声明                           |
| 400 | AgentIdentityDirectoryService.2009  | invalid custom claim                                                                                                                | 无效的自定义声明                                               | 请检查 JWT 中的自定义声明                              |
| 400    | AgentIdentityDirectoryService.3003   | both source_ip and source_vpce are missing in context_attributes                                                                      | 缺少 source_ip 和 source_vpce                              | 请确认请求包含 source_ip 或 source_vpce              |
| 400  | AgentIdentityDirectoryService.3004   | invalid source_vpce                                                                                                                  | source_vpce 格式无效                                        | 请检查 x-source-vpce 请求头格式（需为 UUID）                |
| 400  | AgentIdentityDirectoryService.3005  | invalid user_profile                                                                                                                  | user_profile 格式无效                                       | 请检查 x-user-profile 请求头 JSON 格式               |
| 400  | AgentIdentityDirectoryService.3006  | missing user_profile                                                                                                                   | 缺少 user_profile                                        | 请确认请求头中包含 x-user-profile                       |
| 400  | AgentIdentityDirectoryService.3007   | missing context_attributes                                                                                                          | 缺少上下文属性                                               | 请确认请求头中包含 x-context-attributes              |
| 400  | AgentIdentityDirectoryService.3008 | invalid context_attributes                                                                                                           | 上下文属性格式无效                                              | 请检查 x-context-attributes 请求头 JSON 格式           |
| 400    | AgentIdentityDirectoryService.3009  | resource urn {urn} in the request is invalid                                                                                         | 无效的资源 URN                                              | 请检查资源 URN 格式是否正确                              |
| 400   | AgentIdentityDirectoryService.3010  | security token format is invalid                                                                                                       | 无效的安全令牌                                               | 请检查 x-security-token 请求头                     |
| 400 | AgentIdentityDirectoryService.3011    | security token key with issuer {issuer} cannot be found                                                                              | 安全令牌密钥未找到                                             | 请联系管理员检查安全令牌配置                                |
| 400    | AgentIdentityDirectoryService.3012   | unknown security token key version {version}                                                                                          | 未知的安全令牌密钥版本                                           | 请检查安全令牌版本                                     |
| 400   | AgentIdentityDirectoryService.3013  | principal id {id} in the user profile is invalid                                                                                    | 无效的 Principal ID                                       | 请检查 Principal ID 格式                           |
| 404    | AgentIdentityDirectoryService.3014  | user id {user_id} in the user profile cannot be found                                                                                 | 用户未找到                                                  | 请检查用户 ID 是否正确                                  |
   
