Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rpc error: code = InvalidArgument desc = Resource name should start with "/projects/<PROJECT_ID>/" #1349

Closed
mcandre opened this issue Mar 7, 2019 · 7 comments
Assignees
Labels
api: scheduler type: docs Improvement to the documentation for an API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@mcandre
Copy link

mcandre commented Mar 7, 2019

Client

Scheduler

Describe Your Environment

macOS Mojave

Expected Behavior

Can create jobs using the Go Google Cloud Scheduler API, using projects/my-cool-project/locations/us-east-1 parent prefix, as described in the official Go Google Cloud Scheduler API documentation.

https://godoc.org/google.golang.org/genproto/googleapis/cloud/scheduler/v1beta1#CreateJobRequest

https://godoc.org/google.golang.org/genproto/googleapis/cloud/scheduler/v1beta1#Job

Actual Behavior

All relevant godocs for this claim that the right syntax is project/<project>/locations/<location> for the parent string. However, when I actually try to use this syntax, I get an error from the Go Google Cloud Scheduler API:

rpc error: code = InvalidArgument desc = Resource name should start with "/projects/<PROJECT_ID>/"

Let's set aside the fact that specifying a parent project string is redundant for create job request objects, when the underlying job structure already includes this information in the job name. This generic error message does not indicate which part of the create job request is misconfigured. I just don't know.

I am trying to dig through the godocs to identify the right request format. Also leaning on the compiler to alert me to any missing fields. Note that the Parent field was not required by the compiler, as the public constructors for the create request object are just the struct literal, which of course allows such logically required fields to be omitted accidentally in practice.

Is it the Parent field of the schedulerpb.CreateJobRequest? Is it the Name field of the schedulerpb.Job? I tried adding a forward slash prefix (/) to one, the other, and both request objects.

None of these configurations succeeds. Furthermore, some of the configurations actually produced an error message claiming that /project/my-cool-project/locations/us-east1 should begin with /project/my-cool-project/locations/us-east1.

That error message was particularly confusing, as a string generally begins with its own contents. I haven't dove deep into the implementation, but I am curious if the validation code is suspect, or if the documentation is simply out of date. Or shudder, if the Go API may be out of date with the scheduler RPC running on the servers.

What is the exact syntax for submitting a valid create job request through the Go API? Could you please give a complete example to disambiguate?

@mcandre
Copy link
Author

mcandre commented Mar 7, 2019

Update: Based on a similar error conversation hashicorp/terraform-provider-google#3086 , I think that I was using the wrong format for the Topic portion of my create job request objects.

Would be good to:

  • Improve the Go error messages to clarify which request object type is misconfigured
  • Improve the Go error messages to clarify which field name is misconfigured
  • Restrict Go type public constructors so that validation happens earlier, client side.

@yoshi-automation yoshi-automation added the triage me I really want to be triaged. label Mar 8, 2019
@jeanbza
Copy link
Member

jeanbza commented Mar 8, 2019

Thanks. You're right, we could do better here. Labeling feature request to make errors better. We unfortunately can't change the interface (constructors, input params) as that'd be a breaking change, but I suspect we could do better with errors and docs.

@jeanbza jeanbza added type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. api: firestore Issues related to the Firestore API. type: docs Improvement to the documentation for an API. and removed triage me I really want to be triaged. labels Mar 8, 2019
@odeke-em
Copy link
Contributor

Thank you for the report @mcandre and @jadekler!

Thanks. You're right, we could do better here. Labeling feature request to make errors better. We unfortunately can't change the interface (constructors, input params) as that'd be a breaking change, but I suspect we could do better with errors and docs.

@jadekler @broady should we perhaps add client-side validation for the various methods?
I currently don't see any in

func (c *CloudSchedulerClient) CreateJob(ctx context.Context, req *schedulerpb.CreateJobRequest, opts ...gax.CallOption) (*schedulerpb.Job, error) {
ctx = insertMetadata(ctx, c.xGoogMetadata)
opts = append(c.CallOptions.CreateJob[0:len(c.CallOptions.CreateJob):len(c.CallOptions.CreateJob)], opts...)
var resp *schedulerpb.Job
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
resp, err = c.cloudSchedulerClient.CreateJob(ctx, req, settings.GRPC...)
return err
}, opts...)
if err != nil {
return nil, err
}
return resp, nil
}

We've got all of the expectations defined for the various public API definitions and can look them up in the googleapis/googleapis/*.yaml files such as:

Resource URL
Targets https://github.com/googleapis/googleapis/blob/37386f1ebcaed51bcb7d15d00124d22c38606e45/google/cloud/scheduler/v1beta1/target.proto#L35-L304
Scheduler required fields for various RPCs https://github.com/googleapis/googleapis/blob/master/google/cloud/scheduler/v1beta1/cloudscheduler_gapic.yaml#L25-L262

and etc in the respective yml files.

@odeke-em
Copy link
Contributor

Aha I hadn't noticed that that code is generated

// Code generated by gapic-generator. DO NOT EDIT.

@jeanbza jeanbza added api: scheduler and removed api: firestore Issues related to the Firestore API. labels Apr 4, 2019
@odeke-em
Copy link
Contributor

odeke-em commented Apr 4, 2019

Alright, I've filed a bug on the issue Cloud Scheduler issue tracker https://issuetracker.google.com/issues/129926970

@jeanbza jeanbza closed this as completed Apr 4, 2019
@odeke-em
Copy link
Contributor

Hello again @mcandre! As per the reported issue https://issuetracker.google.com/issues/129926970 I got back information that the engineering team has fixed the error message and now it should return
an error talking about "projects/<PROJECT_ID>/topics/<TOPIC_ID>"
Screen Shot 2019-06-17 at 9 46 56 AM

@shuwenhe
Copy link

rpc error: code = InvalidArgument desc = [Argument] userId format incorrect
*

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: scheduler type: docs Improvement to the documentation for an API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

No branches or pull requests

5 participants