Skip to content
This repository has been archived by the owner on Sep 5, 2023. It is now read-only.

grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with status = StatusCode.INVALID_ARGUMENT #47

Closed
ibbadhafeez opened this issue Apr 1, 2021 · 7 comments
Labels
api: recaptchaenterprise Issues related to the googleapis/python-recaptcha-enterprise API. type: question Request for information or clarification. Not an issue.

Comments

@ibbadhafeez
Copy link

ibbadhafeez commented Apr 1, 2021

I am trying to test this library for a project and running into this issue where create_assessment call fails.

Environment details

  • OS type and version:
    MAC OSX 10.15.7

  • Python version: python --version
    python 3.8.6 (can be reproduced with python3.9.2)

  • pip version: pip --version
    pip 21.0.1

  • google-cloud-recpatchaenterprise version: pip show google-cloud-recpatchaenterprise
    Name: google-cloud-recaptcha-enterprise
    Version: 0.3.0
    Summary: UNKNOWN
    Home-page: https://github.com/googleapis/python-recaptcha-enterprise
    Author: Google LLC
    Author-email: [email protected]
    License: Apache 2.0
    Location: /Users/dev/.local/share/virtualenvs/test-google-recaptcha-enterprise-yBATfFin/lib/python3.8/site-packages
    Requires: google-api-core, proto-plus
    Required-by:

Steps to reproduce

  1. pipenv shell
  2. pipenv install google-cloud-recaptcha-enterprise
  3. export GOOGLE_APPLICATION_CREDENTIALS=<path-to-json-file>
  4. Copy the example from here, replace relevant variables and run it.

Stack trace

Traceback (most recent call last):
  File "/Users/dev/.local/share/virtualenvs/test-google-recaptcha-enterprise-yBATfFin/lib/python3.8/site-packages/google/api_core/grpc_helpers.py", line 73, in error_remapped_callable
    return callable_(*args, **kwargs)
  File "/Users/dev/.local/share/virtualenvs/test-google-recaptcha-enterprise-yBATfFin/lib/python3.8/site-packages/grpc/_channel.py", line 923, in __call__
    return _end_unary_response_blocking(state, call, False, None)
  File "/Users/dev/.local/share/virtualenvs/test-google-recaptcha-enterprise-yBATfFin/lib/python3.8/site-packages/grpc/_channel.py", line 826, in _end_unary_response_blocking
    raise _InactiveRpcError(state)
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
	status = StatusCode.INVALID_ARGUMENT
	details = "Request contains an invalid argument."
	debug_error_string = "{"created":"@1617270971.707825000","description":"Error received from peer ipv4:74.125.193.95:443","file":"src/core/lib/surface/call.cc","file_line":1068,"grpc_message":"Request contains an invalid argument.","grpc_status":3}"
>

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "test_recaptcha_enterprise.py", line 24, in <module>
    response = client.create_assessment(request)
  File "/Users/dev/.local/share/virtualenvs/test-google-recaptcha-enterprise-yBATfFin/lib/python3.8/site-packages/google/cloud/recaptchaenterprise_v1/services/recaptcha_enterprise_service/client.py", line 442, in create_assessment
    response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
  File "/Users/dev/.local/share/virtualenvs/test-google-recaptcha-enterprise-yBATfFin/lib/python3.8/site-packages/google/api_core/gapic_v1/method.py", line 145, in __call__
    return wrapped_func(*args, **kwargs)
  File "/Users/dev/.local/share/virtualenvs/test-google-recaptcha-enterprise-yBATfFin/lib/python3.8/site-packages/google/api_core/grpc_helpers.py", line 75, in error_remapped_callable
    six.raise_from(exceptions.from_grpc_error(exc), exc)
  File "<string>", line 3, in raise_from
google.api_core.exceptions.InvalidArgument: 400 Request contains an invalid argument.

The error can be reproduced with and without VPN.

@product-auto-label product-auto-label bot added the api: recaptchaenterprise Issues related to the googleapis/python-recaptcha-enterprise API. label Apr 1, 2021
@busunkim96
Copy link
Contributor

Hi @hafeezibbad,

Could you try using the REST API instructions as well to see if you can reproduce the error? The python client library unfortunately makes it hard to access error details right now (see googleapis/python-api-core#99). If you send a request directly to the REST API it may have additional details about which field is invalid.

@busunkim96 busunkim96 added type: question Request for information or clarification. Not an issue. needs more info This issue needs more information from the customer to proceed. and removed needs more info This issue needs more information from the customer to proceed. labels Apr 1, 2021
@busunkim96 busunkim96 self-assigned this Apr 1, 2021
@ibbadhafeez
Copy link
Author

ibbadhafeez commented Apr 7, 2021

Could you try using the REST API instructions as well to see if you can reproduce the error?

Hi, I can not reproduce the same error with API key. Everything works as expected with RestAPI client but the problem only appears when I am using the library.
I was doubting that some role/permission was missing on the service account I am using with the library but I have confirmed it with two different service accounts and error is reproducible in both cases.

@ibbadhafeez
Copy link
Author

I have noticed one more thing that if projects/ is not project_name, we get the same error.

@busunkim96
Copy link
Contributor

I have noticed one more thing that if projects/ is not project_name, we get the same error.

I don't understand - were you not following the pattern projects/your_project_name when passing the project name?

@ocervell
Copy link

Just had the same, your project_id might just be wrong for this call. Unfortunately the error message is so misleading that you have to try it in the REST API to get the full list of errors.

@ibbadhafeez
Copy link
Author

ibbadhafeez commented Apr 20, 2021

I don't understand - were you not following the pattern projects/your_project_name when passing the project name?

I created new service account, added recaptcha-related roles to the service account and that worked. While testing the new account, I found the issue that projects/ is necessary. This is not clear in the guide here.

Unfortunately the error message is so misleading that you have to try it in the REST API to get the full list of errors.

Yes, this is an issue. It makes debugging so difficult. I have not run into this issue with REST API at all.
One more thing to mention here, the data model for RestAPI is different from the data model in library, for example, Rest API does not include risk_analysis unlike python-recaptcha-enterprise library. So, there no intuitive direct mapping between Rest API and library's functionality.

@parthea
Copy link
Contributor

parthea commented Apr 15, 2023

I'm going to close this issue as obsolete as details is now populated with more helpful information showing "Invalid Parent resource name <PROJECT_ID>" instead of "Request contains an invalid argument".

In addition, the docstring of CreateAssessmentRequest mentions that the format of the parent field should be projects/{project}.

Traceback (most recent call last):
  File "/usr/local/google/home/partheniou/.pyenv/versions/py39/lib/python3.9/site-packages/google/api_core/grpc_helpers.py", line 72, in error_remapped_callable
    return callable_(*args, **kwargs)
  File "/usr/local/google/home/partheniou/.pyenv/versions/py39/lib/python3.9/site-packages/grpc/_channel.py", line 946, in __call__
    return _end_unary_response_blocking(state, call, False, None)
  File "/usr/local/google/home/partheniou/.pyenv/versions/py39/lib/python3.9/site-packages/grpc/_channel.py", line 849, in _end_unary_response_blocking
    raise _InactiveRpcError(state)
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
        status = StatusCode.INVALID_ARGUMENT
        details = "Invalid Parent resource name 'xxxxx'"
        debug_error_string = "UNKNOWN:Error received from peer ipv4:74.125.124.95:443 {created_time:"2023-04-15T11:59:24.659107248+00:00", grpc_status:3, grpc_message:"Invalid Parent resource name \'xxxx\'"}"
>

@parthea parthea closed this as completed Apr 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api: recaptchaenterprise Issues related to the googleapis/python-recaptcha-enterprise API. type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

4 participants