[go: nahoru, domu]

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

Improve gRPC error message when request is invalid #12764

Open
ithomaslin opened this issue May 31, 2024 · 7 comments
Open

Improve gRPC error message when request is invalid #12764

ithomaslin opened this issue May 31, 2024 · 7 comments
Labels
api: run Issues related to the Cloud Run API. external This issue is blocked on a bug with the actual product. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@ithomaslin
Copy link

Hi folks,

from google.cloud.run_v2 import ListJobsRequest
from google.oauth2 import service_account
import google.cloud.run_v2 as run_v2

credentials = service_account.Credentials.from_service_account_file("key.json")

run_client = run_v2.ServicesClient(credentials=credentials)

request = ListJobsRequest(
    parent="parent_name"
)

run_client.list_jobs(request=request)

With the above code, which is following the sample provided in the official documentation. However, I got this error message:

grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
	status = StatusCode.UNIMPLEMENTED
	details = "Operation is not implemented, or supported, or enabled."
	debug_error_string = "UNKNOWN:Error received from peer ipv6:%5B2404:6800:4012::200a%5D:443 {created_time:"2024-05-31T19:40:11.155916+08:00", grpc_status:12, grpc_message:"Operation is not implemented, or supported, or enabled."}"
>
@ithomaslin ithomaslin changed the title Got Operation is not implemented, or supported, or enabled error when calling list_jobs with run_v2 library google-cloud-run: Got Operation is not implemented, or supported, or enabled error when calling list_jobs with run_v2 library May 31, 2024
@parthea
Copy link
Contributor
parthea commented Jun 3, 2024

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.

@parthea parthea self-assigned this Jun 3, 2024
@parthea parthea added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. priority: p2 Moderately-important priority. Fix may not be included in next release. external This issue is blocked on a bug with the actual product. api: run Issues related to the Cloud Run API. labels Jun 3, 2024
@ajoy39
Copy link
ajoy39 commented Jun 3, 2024

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 googleapis/python-datacatalog#33

I also added a comment to the issue @parthea linked as well

@parthea
Copy link
Contributor
parthea commented Jun 3, 2024

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)

parent (str):
Required. The location and project to list
resources on. Format:
projects/{project}/locations/{location}, where
{project} can be project id or number.

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.

@ajoy39
Copy link
ajoy39 commented Jun 3, 2024

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

@parthea
Copy link
Contributor
parthea commented Jun 3, 2024

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).

@ajoy39
Copy link
ajoy39 commented Jun 3, 2024

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

@parthea
Copy link
Contributor
parthea commented Jun 3, 2024

@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.

@parthea parthea removed their assignment Jun 4, 2024
@parthea parthea changed the title google-cloud-run: Got Operation is not implemented, or supported, or enabled error when calling list_jobs with run_v2 library Improve gRPC error message when request is invalid Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: run Issues related to the Cloud Run API. external This issue is blocked on a bug with the actual product. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

3 participants