View a markdown version of this page

开启调试消息 - Amazon Bedrock AgentCore

开启调试消息

在开发网关时,您可以打开调试消息以返回有关目标配置问题的详细信息,包括 lambda 函数错误、出口授权程序错误、目标规范参数验证错误。开启调试消息后,如果您在调用网关时出现问题,响应将返回消息以帮助您进行调试。

要打开调试消息,请执行以下任一操作:

  • 如果您使用 AgentCore CLI 创建网关,则调试功能会自动开启。

  • 如果您使用 AWS 管理控制台创建网关,则默认情况下调试处于开启状态。该选项位于网关详细信息部分的其他配置下。

  • 如果您使用 AWS CLI 或 S AWS DK,请将该exceptionLevel值设置为发出CreateGatewayUpdateGateway请求DEBUG时的值。

网关调试完毕后,您可以更新网关以关闭调试消息,这样发送给最终用户的消息只会显示未指定的内部错误。

要关闭调试消息,请执行以下任一操作:

  • 创建或编辑网关时,在 AWS 管理控制台中,展开网关详细信息部分中的其他配置,并取消选中异常级别调试旁边的复选框。

  • 在 AWS CLI 或 S AWS DK 中,当您UpdateGateway发出CreateGateway或请求关闭调试时,请省略该exceptionLevel字段。

开启和关闭调试时的网关响应示例

例如,假设用户无权调用网关所针对的 Lambda 函数。调用此函数的请求将返回不同的消息,具体取决于调试处于开启还是关闭状态:

  • 正在调试-将在内容text字段和响应的字段中返回详细的_meta错误消息,如以下示例所示:

    { "jsonrpc": "2.0", "id": 24, "result": { "content": [ { "type": "text", "text": "Access denied while invoking Lambda function arn:aws:lambda:us-west-2:123456789012:function:TestGatewayLambda. Check the permissions on the Lambda function and Gateway execution role, and retry the request." } ], "_meta": { "debug": { "type": "text", "text": "Access denied while invoking Lambda function arn:aws:lambda:us-west-2:123456789012:function:TestGatewayLambda. Check the permissions on the Lambda function and Gateway execution role, and retry the request." } }, "isError": true } }
  • 调试关闭 — 将在响应的内容text字段中返回一条通用错误消息,如以下示例所示:

    { "jsonrpc": "2.0", "id": 24, "result": { "content": [ { "type": "text", "text": "An internal error occurred. Please retry later." } ], "isError": true } }