错误消息

了解如何解决 Vertex AI Vision 引发的一些错误。本主题讨论解决方法需要多个步骤且无法在错误消息中简单说明的错误。

如需了解错误处理的推荐做法,请参阅 Cloud API 文档

权限

应用默认凭据不可用

如果收到此消息:

The Application Default Credentials are not available. They are
available if running in Google Compute Engine. Otherwise, the
environment variable GOOGLE_APPLICATION_CREDENTIALS must be defined
pointing to a file defining the credentials.
See https://developers.google.com/accounts/docs/application-default-credentials
for more information.

权限遭拒

如果收到此消息:

ERROR: (gcloud.auth.application-default.print-access-token) File /path/to/key.json
(pointed by GOOGLE_APPLICATION_CREDENTIALS environment variable) does not exist!
{
  "error": {
    "code": 403,
    "message": "The request is missing a valid API key.",
    "status": "PERMISSION_DENIED"
  }
}

确认 GOOGLE_APPLICATION_CREDENTIALS 环境变量中存储的位置中包含有效的服务账号密钥 JSON 文件,并且该变量指向正确的位置。

如需诊断此错误,请尝试从您尝试调用 Vertex AI Vision API 的文件夹中打开服务账号密钥文件。

cat $GOOGLE_APPLICATION_CREDENTIALS

Forbidden: 403 POST API has not been used or is disabled

如果收到此消息:

Forbidden: 403 POST Vertex AI Vision API has not been used in
project # before or it is disabled.
Enable it by visitng [url] then retry.
If you enabled this API recently, wait a few minutes for the action to
propagate and retry.

  1. 访问错误消息中指定的链接,并启用 Vertex AI Vision API。 等待几分钟,然后重试。
  2. 验证您是否在 GOOGLE_APPLICATION_CREDENTIALS 环境变量中存储了有效的服务账号密钥 JSON 文件。如需诊断此错误,请从您尝试调用 Vertex AI Vision API 的文件夹中打开服务账号密钥文件。
    cat $GOOGLE_APPLICATION_CREDENTIALS
    

参数无效

不支持的 API 版本

示例:向不支持相应操作的 API 版本发出请求。

message: "The requested operation is unsupported for the API version."

Bad Request

发出 API 请求,但请求字段存在一个或多个违规问题。每个违规行为都会在 google.rpc.BadRequest 详情中捕获为 field_violations

message: "Request contains an invalid argument."
details {
  [type.googleapis.com/google.rpc.BadRequest] {
    field_violations { field: "foo" description: "bar" }
  }
}

项目编号无效

提供无效的项目编号时。项目编号示例:848757893952147483648。

message: "Invalid project number used: 848757893952147483648."
details {
    [type.googleapis.com/google.rpc.ErrorInfo] {
      reason: "INVALID_PROJECT_NUMBER"
      domain: "visionai.googleapis.com"
    }
}

资源格式无效

资源格式无效时。项目编号示例为 1234,位置 ID 示例为 us-central1。

message: "Invalid Resource Used: project/1234/location/us-central1. Valid format should be "
"projects/{project_number}/locations/{location_id}."
details {
    [type.googleapis.com/google.rpc.ErrorInfo] {
      reason: "INVALID_RESOURCE_FORMAT"
      domain: "visionai.googleapis.com"
    }
}

先决条件失败

缺少视频数据

对于某些 API(例如用于分区级注释的 CreateAnnotation),必须先将视频数据流式传输到资产,才能推断出资产的开始时间。否则,系统会触发以下错误。

message: "Asset doesn't have start time inferred yet. Should ingest asset and retry."
details {
    [type.googleapis.com/google.rpc.ErrorInfo] {
      reason: "FAILED_PRECONDITION"
      domain: "visionai.googleapis.com"
    }
}

配额和限制

已超出配额

如果收到此消息:

RESOURCE_EXHAUSTED: Quota exceeded.

您已达到每分钟或每日配额的上限。请查看使用 Vertex AI Vision 的配额和限制

您可以通过 Google Cloud 控制台申请增加配额。