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

[Bug]: GCS IO publishes uninformative error message #26769

Closed
2 of 15 tasks
tvalentyn opened this issue May 18, 2023 · 10 comments
Closed
2 of 15 tasks

[Bug]: GCS IO publishes uninformative error message #26769

tvalentyn opened this issue May 18, 2023 · 10 comments

Comments

@tvalentyn
Copy link
Contributor

What happened?

When I ran a wordcount pipeline with an output set to a bucket in a different project (causing permission errors), I saw following output in the console:

  File "apache_beam/runners/common.py", line 1731, in apache_beam.runners.common._OutputHandler.finish_bundle_outputs
  File "/usr/local/lib/python3.9/site-packages/apache_beam/io/iobase.py", line 1202, in finish_bundle
    self.writer.close(),
  File "/usr/local/lib/python3.9/site-packages/apache_beam/io/filebasedsink.py", line 434, in close
    self.sink.close(self.temp_handle)
  File "/usr/local/lib/python3.9/site-packages/apache_beam/io/textio.py", line 524, in close
    super().close(file_handle)
  File "/usr/local/lib/python3.9/site-packages/apache_beam/io/filebasedsink.py", line 167, in close
    file_handle.close()
  File "/usr/local/lib/python3.9/site-packages/apache_beam/io/filesystemio.py", line 215, in close
    self._uploader.finish()
  File "/usr/local/lib/python3.9/site-packages/apache_beam/io/gcp/gcsio.py", line 829, in finish
    self._upload_thread.last_error.message)  # pylint: disable=raising-bad-type
AttributeError: 'HttpForbiddenError' object has no attribute 'message' [while running 'Write/Write/WriteImpl/WriteBundles-ptransform-58']

Looks like not all possible errors have the message attribute, and the code needs to account for it.

Relevant PR: #24449

Issue Priority

Priority: 2 (default / most bugs should be filed as P2)

Issue Components

  • Component: Python SDK
  • Component: Java SDK
  • Component: Go SDK
  • Component: Typescript SDK
  • Component: IO connector
  • Component: Beam examples
  • Component: Beam playground
  • Component: Beam katas
  • Component: Website
  • Component: Spark Runner
  • Component: Flink Runner
  • Component: Samza Runner
  • Component: Twister2 Runner
  • Component: Hazelcast Jet Runner
  • Component: Google Cloud Dataflow Runner
@tvalentyn
Copy link
Contributor Author

cc: @BjornPrime who is working on GCS IO

@BjornPrime
Copy link
Contributor

The client swap should take care of this. I'll claim it for now and close it once the swap is merged.

@BjornPrime
Copy link
Contributor

.take-issue

@cozos
Copy link
Contributor

cozos commented Aug 31, 2023

This code:

raise type(self._upload_thread.last_error)(
          "Error while uploading file %s: %s",
          self._path,
          self._upload_thread.last_error.message if hasattr(self._upload_thread.last_error, "message") else "")  # pylint: disable=raising-bad-type

Totally breaks Google's HttpError for me, since it overrides response which is expected to be dictionary rather than a message.

Calling HttpError.status_code results in this exception:

File "/generate_dataset_docker_pybinary.runfiles/cruise_ws/cruise/mlp/cfs/projects/temporal_understanding/generate_dataset_docker_pybinary_exedir/apitools/base/py/exceptions.py", line 78, in status_code
    return int(self.response['status'])
TypeError: string indices must be integers [while running 'Publish dataset/Write to big query/StoreArtifacts/WriteArtifact-ptransform-158']

@cozos
Copy link
Contributor

cozos commented Aug 31, 2023

This should probably be:

raise BeamGcsError("error while uploading file %s...") from self._upload_thread.last_error

@cozos
Copy link
Contributor

cozos commented Aug 31, 2023

@tvalentyn If you agree I can make a PR

@liferoad
Copy link
Collaborator

Note that #28079 will remove apitools. @BjornPrime FYI.

@tvalentyn
Copy link
Contributor Author

@cozos SGTM. You can raise a RuntimeError. As mentioned, this would hopefully be moot soon though.

@cozos
Copy link
Contributor

cozos commented Sep 15, 2023

@tvalentyn #28470

@tvalentyn
Copy link
Contributor Author

Thanks, @cozos !

@github-actions github-actions bot added this to the 2.51.0 Release milestone Sep 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants