Open ithomaslin opened 5 months ago
Hi @ithomaslin ,
This appears to be an issue with the API. Thanks for reporting the issue in the API specific issue tracker (https://issuetracker.google.com/issues/343845155). We'll keep this issue open and update it as more information is available.
I am also getting this error when trying to use runjob, I followed a link from an issue that was last updated in Novemeber with the same problem so I am not sure if this is truly an issue with the API or rather it's our code but the python client (which is still version 0.X to be fair) is giving the wrong error return.
Here's the link to the issue I mentioned, last two comments relate to Cloud Run Jobs https://github.com/googleapis/python-datacatalog/issues/33
I also added a comment to the issue @parthea linked as well
I was able to re-create the error using the following code
from google.cloud.run_v2 import ListJobsRequest
import google.cloud.run_v2 as run_v2
run_client = run_v2.JobsClient()
request = ListJobsRequest(
parent="projects/<project ID>"
)
run_client.list_jobs(request=request)
I switched from gRPC
to REST
transport by setting the transport
argument of JobsClient
to "rest"
, and found a more helpful error message that suggested the value of the parent
argument is incorrect.
from google.cloud.run_v2 import ListJobsRequest
import google.cloud.run_v2 as run_v2
run_client = run_v2.JobsClient(transport="rest")
request = ListJobsRequest(
parent="projects/<project ID>"
)
run_client.list_jobs(request=request)
Error when using REST
transport.
ValueError: Invalid request.
Some of the fields of the request message are either not initialized or initialized with an invalid value.
Please make sure your request matches at least one accepted HTTP binding.
To match a binding the request message must have all the required fields initialized with values matching their patterns as listed below:
URI: "/v2/{parent=projects/*/locations/*}/jobs"
Required request fields:
field: "parent", pattern: "projects/*/locations/*"
Essentially, the value for the parent
argument of ListJobsRequest
must be in the form projects/<your project>/locations/<your location>
which matches what is documented.
See the updated code below which worked
from google.cloud.run_v2 import ListJobsRequest
import google.cloud.run_v2 as run_v2
run_client = run_v2.JobsClient()
request = ListJobsRequest(
parent="projects/<your project>/locations/<your location>"
)
run_client.list_jobs(request=request)
We'll keep this issue open as the error message from gRPC should be improved to the level that we see when using REST
transport.
I will also switch to the REST transport and see if I am running into something similar with run job, fwiw this is my code
def start_job_if_non_started(sender, **kwargs):
client = run_v2.JobsClient()
request: RunJobRequest = run_v2.RunJobRequest(
name=f"projects/{app_settings.PROJECT_ID}/location/{app_settings.REGION}/jobs/{app_settings.SINGLE_JOB_QUEUE}"
)
try:
client.run_job(request=request)
except Exception as e:
print(e)
Secondarily, part of the issue might be docs related, this is the doc for RunJobRequest, the text description of validate
makes me think these docs might not be accurate, because I'm not sure how RunJob would delete resources in GCP
Thanks for the update @ajoy39. Please let me know if you're still unable to resolve the issue after trying REST
. I've reached out to the API team to request a fix for the docs issue (Googlers see cl/639895039).
sigh sorry for wasting your time y'all, my problem ended up being a simple typo. location
instead of locations
in the job name. I did miss that because of the vague error message (seems more like Exception not implemented than Endpoint not implemented 😀 ) but thats on me lol
tldr: Docs are fine, gRPC Transport ate the error message like it did for OP, but underlying issue was a typo
@ajoy39 Thanks for the update. I'm glad that you found the issue! I'll keep this issue open as the error message for gRPC could be improved.
I'm going to transfer this issue to the repository for the code generator where we can work to improve the gRPC error message.
Hi folks,
With the above code, which is following the sample provided in the official documentation. However, I got this error message: