You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

部署Cloud Endpoints遇Unresolved type '.google.protobuf.Timestamp'错误求助

Fixing "Unresolved type '.google.protobuf.Timestamp'" in Cloud Endpoints Deployment

Let's break down why you're hitting this error and walk through how to fix it:

The Root Cause

When generating api_descriptor.pb, Cloud Endpoints needs all proto definitions your service depends on—including the standard google.protobuf.Timestamp type. Your current protoc command only packages your own service.proto and doesn't include the Timestamp definition. Plus, your proto file's vendor-specific import path is causing protoc to struggle resolving the type correctly.

Step 1: Correct the Proto File Import

First, update your proto file to use the standard, protoc-friendly import path for Timestamp:

syntax = "proto3"; 
package proto; 

// Replace the vendor-specific import with this standard one
import "google/protobuf/timestamp.proto"; 

message CandleStick { 
  string ID = 1; 
  double Open = 2; 
  double Close = 3; 
  double High = 4; 
  double Low = 5; 
  google.protobuf.Timestamp TimeStamp = 6; 
}

Step 2: Update the Protoc Command to Include Dependencies

You need two key additions to your protoc command:

  1. A valid include path so protoc can locate google/protobuf/timestamp.proto
  2. The --include_imports flag to bundle all dependent proto definitions into api_descriptor.pb

Option A: System-wide Protobuf Installation

If you have protobuf installed on your system (e.g., via apt install protobuf-compiler on Ubuntu), use this command:

protoc \
 --plugin=protoc-gen-go=${GOBIN}/protoc-gen-go \
 -I . \
 -I /usr/include \  # Path to standard protobuf system includes
 proto/service.proto \
 --descriptor_set_out=api_descriptor.pb \
 --include_imports \  # Bundles all imported proto definitions into the descriptor set
 --go_out=plugins=grpc:. \

Option B: Go Module-managed Protobuf

If you're using Go modules and don't have a system-wide protobuf install, use this command to dynamically resolve the correct include path:

protoc \
 --plugin=protoc-gen-go=${GOBIN}/protoc-gen-go \
 -I . \
 -I $(go list -f '{{.Dir}}' github.com/golang/protobuf/ptypes/timestamp)/.. \  # Points to the parent directory of the timestamp proto
 proto/service.proto \
 --descriptor_set_out=api_descriptor.pb \
 --include_imports \
 --go_out=plugins=grpc:. \

Step 3: Validate the Fix

Regenerate api_descriptor.pb with the updated command, then re-run your Cloud Endpoints deploy validation:

gcloud endpoints services deploy api_descriptor.pb api_config.yaml --validate-only

This should resolve the "Unresolved type" error, as Cloud Endpoints will now have access to the full google.protobuf.Timestamp definition in the bundled descriptor set.

内容的提问来源于stack exchange,提问作者user5353256

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 04:03:20