INTERNAL error when uploading proto file descriptor set with resource references.

116 views
Skip to first unread message

Oscar Söderlund

unread,
Jul 18, 2020, 9:50:30 AM7/18/20
to Google Cloud Endpoints
We're using part of the annotations from https://github.com/googleapis/api-common-protos to annotate our resources and resource references as described in the AIP guidelines (https://google.aip.dev/).

We're getting a non-descript error when uploading our full file descriptor set to Cloud Endpoints, and I've managed to narrow it down to a small example:

import "google/api/annotations.proto";
import "google/api/client.proto";
import "google/api/field_behavior.proto";
import "google/api/resource.proto";

message Example {
  option (google.api.resource) = {
    type: "example.com/Example"
    pattern: "examples/{example}"
    plural: "examples"
    singular: "example"
  };
  string name = 1;
}

service ExampleService {
  option (google.api.default_host) = "example.com";

  rpc GetExample(GetExampleRequest) returns (Example) {
    option (google.api.http) = {
      get: "/v1beta1/{name=examples/*}"
    };
    option (google.api.method_signature) = "name";
  };
}

message GetExampleRequest {
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "example.com/Example"
    }
  ];
}

When uploading the above service definition, the following error is given from gcloud endpoints services deploy --validate-only:

ERROR: (gcloud.endpoints.services.deploy) INTERNAL: Failed to convert server response to JSON

When removing the resource reference annotation, the command completes successfully.

Are there restrictions on using resource types and resource references with Cloud Endpoints?

What do you propose as a solution to this specific problem? The best approach I can come up with now is a tool that scrubs away all resource reference annotations before uploading to Cloud Endpoints.

Any advice would be much appreciated!

Kristian Drucker

unread,
Jul 18, 2020, 11:01:13 AM7/18/20
to Google Cloud Endpoints
I have had the same issue. Solved it for now by just removing, but I can confirm it on my end too that the same thing is happening. Took me a while to figure out that it was annotations back when I started my migration.

Oscar Söderlund

unread,
Jul 19, 2020, 10:23:53 AM7/19/20
to Google Cloud Endpoints
Thanks for confirming Kristian, I did the same by removing. For anyone else who run into this issue, here's a Go code snippet for scrubbing resource references from a file descriptor set proto file:

package main

import (
"flag"
"io/ioutil"
"log"
"os"

)

func main() {
var filename string
flag.StringVar(&filename, "f", "", "file descriptor set to scrub")
flag.Parse()
if filename == "" {
flag.Usage()
os.Exit(1)
}
input, err := ioutil.ReadFile(filename)
if err != nil {
log.Fatal(err)
}
var fileDescriptorSet descriptorpb.FileDescriptorSet
if err := proto.Unmarshal(input, &fileDescriptorSet); err != nil {
log.Fatal(err)
}
for _, file := range fileDescriptorSet.GetFile() {
for _, message := range file.GetMessageType() {
scrubResourceReferences(message)
}
}
output, err := proto.Marshal(&fileDescriptorSet)
if err != nil {
log.Fatal(err)
}
if err := ioutil.WriteFile(filename, output, 0o600); err != nil {
log.Fatal(err)
}
}

func scrubResourceReferences(message *descriptorpb.DescriptorProto) {
for _, field := range message.GetField() {
if field.GetOptions() != nil {
proto.ClearExtension(field.GetOptions(), annotations.E_ResourceReference)
}
}
for _, nestedMessage := range message.NestedType {
scrubResourceReferences(nestedMessage)
}
}


Reply all
Reply to author
Forward
0 new messages