Skip to content
This repository has been archived by the owner on Feb 28, 2024. It is now read-only.

INVALID_ARGUMENT error on gcloud asset export --content-type relationship #298

Closed
kbroughton opened this issue Sep 24, 2021 · 14 comments
Closed
Assignees
Labels
api: cloudasset Issues related to the googleapis/python-asset API. external This issue is blocked on a bug with the actual product. priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@kbroughton
Copy link

Environment details

  • MacOsx 11.13.1 big sur
  • Python version: Python 3.9.6
  • pip version: 21.1.3
  • google-cloud-asset version: gcloud version

Google Cloud SDK 358.0.0
alpha 2021.09.17
beta 2021.09.17
bq 2.0.71
core 2021.09.17
gsutil 4.68

Steps to reproduce

According to the docs https://cloud.google.com/sdk/gcloud/reference/asset/export?hl=it
asset export should work with content-type=relationship.

  1. Create a bq dataset.
  2. Run the asset export command with gcloud or python sdk.

It works with content-type=resource:

gcloud   beta asset export    --content-type resource    --project $PROJECT_ID    --output-bigquery-force --bigquery-table "projects/$PROJECT_ID/datasets/$DATASET/tables/$TABLE"  --snapshot-time '2021-09-23' --partition-key REQUEST_TIME

But this does not:

gcloud   beta asset export    --content-type relationship    --project $PROJECT_ID    --output-bigquery-force --bigquery-table "projects/$PROJECT_ID/datasets/$DATASET/tables/$TABLE"  --snapshot-time '2021-09-23' --partition-key REQUEST_TIME

ERROR: (gcloud.beta.asset.export) code: 400
message: Request contains an invalid argument.
status: INVALID_ARGUMENT

Code example

      Uncomment when fixed: causes a grpc error
      if partition_key:
        output_config.bigquery_destination.table = '%s_relationship' % (bq_table)
      else:
        output_config.bigquery_destination.table = '%s_relationship_%s' % (bq_table, read_time.strftime('%Y%m%d'))

      response = client.export_assets(
          request={
              'parent': parent,
              'read_time': read_time,
              'content_type': asset_v1.ContentType.RELATIONSHIP,
              'output_config': output_config
          }
     )

Stack trace

googlecloudsdk.api_lib.util.exceptions.HttpException: code: 400
message: Request contains an invalid argument.
status: INVALID_ARGUMENT
ERROR: (gcloud.beta.asset.export) code: 400
message: Request contains an invalid argument.
status: INVALID_ARGUMENT

Making sure to follow these steps will guarantee the quickest resolution possible.

Thanks!

@product-auto-label product-auto-label bot added the api: cloudasset Issues related to the googleapis/python-asset API. label Sep 24, 2021
@busunkim96 busunkim96 self-assigned this Sep 24, 2021
@busunkim96 busunkim96 added 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. labels Sep 24, 2021
@busunkim96
Copy link
Contributor

Hi @kbroughton,

Thank you for the report. It looks like the both gcloud and the library is not surfacing the detailed error. Could you share the version of google-cloud-asset you used?

@kbroughton
Copy link
Author

bin/pip show google-cloud-asset
Name: google-cloud-asset
Version: 3.5.0
Summary: Cloud Asset API API client library
Home-page: https://github.com/googleapis/python-asset
Author: Google LLC
Author-email: googleapis-packages@google.com
License: Apache 2.0
Location: /private/tmp/py-asset/lib/python3.9/site-packages
Requires: google-api-core, google-cloud-access-context-manager, proto-plus, google-cloud-os-config, grpc-google-iam-v1, google-cloud-org-policy, packaging
Required-by:
(py-asset)

I had been using installs of the complete gcloud or sdk. I followed the install instructions in the readme to only install google-cloud-asset for this test. Same result.

@sirius-ed-hammond
Copy link

sirius-ed-hammond commented Sep 27, 2021

This was working in August, but it is failing now with the subject error
Google Cloud SDK [358.0.0]

gcloud beta asset export --organization=xxxxxxx --content-type relationship --output-path gs://xxxx/xxxx/relationships
ERROR: (gcloud.beta.asset.export) code: 400
message: Request contains an invalid argument.
status: INVALID_ARGUMENT

Tried alpha, beta, and GA versions of gcloud 358.0

@kbroughton
Copy link
Author

from google.cloud import asset_v1
Here is the full setup and stacktrace

output_config = asset_v1.OutputConfig()
output_config.bigquery_destination.dataset = 'projects/$PROJECT_ID/datasets/$DATASET'
output_config.bigquery_destination.force = True
partition_spec = asset_v1.PartitionSpec()
partition_spec.partition_key = 'REQUEST_TIME'
output_config.bigquery_destination.partition_spec = partition_spec
output_config.bigquery_destination.table = 'test_resource'
client = asset_v1.AssetServiceClient()

response = client.export_assets(
... request={
... 'parent': parent,
... 'content_type': asset_v1.ContentType.RELATIONSHIP,
... 'output_config': output_config
... }
... )
Traceback (most recent call last):
File "", line 3, in
NameError: name 'parent' is not defined
parent = 'organizations/$ORG_ID'
response = client.export_assets(
... request={
... 'parent': parent,
... 'content_type': asset_v1.ContentType.RELATIONSHIP,
... 'output_config': output_config
... }
... )
Traceback (most recent call last):
File "/private/tmp/py-asset/lib/python3.9/site-packages/google/api_core/grpc_helpers.py", line 66, in error_remapped_callable
return callable_(*args, **kwargs)
File "/private/tmp/py-asset/lib/python3.9/site-packages/grpc/_channel.py", line 946, in call
return _end_unary_response_blocking(state, call, False, None)
File "/private/tmp/py-asset/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 = "Request contains an invalid argument."
debug_error_string = "{"created":"@1632760077.006469000","description":"Error received from peer ipv4:142.250.64.170:443","file":"src/core/lib/surface/call.cc","file_line":1070,"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 "", line 1, in
File "/private/tmp/py-asset/lib/python3.9/site-packages/google/cloud/asset_v1/services/asset_service/client.py", line 475, in export_assets
response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
File "/private/tmp/py-asset/lib/python3.9/site-packages/google/api_core/gapic_v1/method.py", line 142, in call
return wrapped_func(*args, **kwargs)
File "/private/tmp/py-asset/lib/python3.9/site-packages/google/api_core/grpc_helpers.py", line 68, in error_remapped_callable
raise exceptions.from_grpc_error(exc) from exc
google.api_core.exceptions.InvalidArgument: 400 Request contains an invalid argument.

@busunkim96
Copy link
Contributor

@sirius-ed-hammond Thanks for leaving a comment, it's helpful to know this worked in the past but doesn't now.

I'm able to reproduce the error through gcloud using my own project. I'm in the process of filing an issue on the Cloud Asset API team's issue tracker and will get back to you when I have a response.

@busunkim96
Copy link
Contributor

Googlers, see internal issue 201301739.

@busunkim96 busunkim96 added external This issue is blocked on a bug with the actual product. priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. and removed priority: p2 Moderately-important priority. Fix may not be included in next release. labels Sep 27, 2021
@busunkim96
Copy link
Contributor

CC @lvvvvvf

@lvvvvvf
Copy link
Contributor

lvvvvvf commented Sep 27, 2021

We used to have preview in gcloud beta with 1 relationship.

The original plan is GA at the end of this month, so I turned all gcloud to the v1 version which could only be used with for enable listed consumers now. After GA, all will be available to public.

Now there may be some changes to the plan, if so, I will change back the beta behavior. (next month)

Sorry about the inconvenience.

@sirius-ed-hammond
Copy link

If I understand correctly, you disabled the public /beta/ in deference to private GA release for select customers, so people who were using the public beta can no longer do so. Correct?

@lvvvvvf
Copy link
Contributor

lvvvvvf commented Sep 27, 2021

The plan is public GA 9/30, if so, all will turn public, the issue will be solved.

If the plan changed, I will switch back the gcloud beta to serve public the one relationship type next month. Thanks

@sirius-ed-hammond
Copy link

sirius-ed-hammond commented Dec 1, 2021

It has been a few months ... the relationship content-type is still broken for alpha, beta, and GA command invocations.
When might we expect it to be restored at least in beta mode?

$ gcloud asset export --organization=0000 --content-type relationships  --output-path gs://bucket/path
ERROR: (gcloud.asset.export) argument --content-type: Invalid choice: 'relationships'. Did you mean 'relationship'?

$ gcloud asset export --organization=0000 --content-type relationship  --output-path gs://bucket/path
ERROR: (gcloud.asset.export) code: 400
message: Request contains an invalid argument.
status: INVALID_ARGUMENT

$ gcloud --version
Google Cloud SDK 365.0.1
alpha 2021.11.19
beta 2021.11.19
bq 2.0.71
core 2021.11.19
gsutil 5.5
kpt 1.0.0-beta.4
kubectl 1.20.8

@sirius-ed-hammond
Copy link

Created issue tracker https://issuetracker.google.com/issues/209387751 to help raise visibility.

@parthea
Copy link
Contributor

parthea commented Feb 5, 2022

Hi @sirius-ed-hammond @kbroughton,

I'm going to close this issue as a duplicate of https://issuetracker.google.com/issues/209387751 as the issue is specific to product API rather than the client library.

@parthea parthea closed this as completed Feb 5, 2022
@sirius-ed-hammond
Copy link

sirius-ed-hammond commented Feb 7, 2022 via email

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api: cloudasset Issues related to the googleapis/python-asset API. external This issue is blocked on a bug with the actual product. priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to 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

5 participants