Skip to content

google.cloud.error_reporting AttributeError: 'Client' object has no attribute 'project' #3167

@cva

Description

@cva

I am trying to follow the sample code here in an appengine custom flexible runtime and whenever I run the code, I get the following error:

Traceback (most recent call last):
  File "/env/lib/python3.5/site-packages/flask/app.py", line 1994, in __call__
    return self.wsgi_app(environ, start_response)
  File "/env/lib/python3.5/site-packages/flask/app.py", line 1985, in wsgi_app
    response = self.handle_exception(e)
  File "/env/lib/python3.5/site-packages/flask/app.py", line 1540, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/env/lib/python3.5/site-packages/flask/_compat.py", line 33, in reraise
    raise value
  File "/env/lib/python3.5/site-packages/flask/app.py", line 1982, in wsgi_app
    response = self.full_dispatch_request()
  File "/env/lib/python3.5/site-packages/flask/app.py", line 1614, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/env/lib/python3.5/site-packages/flask/app.py", line 1517, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/env/lib/python3.5/site-packages/flask/_compat.py", line 33, in reraise
    raise value
  File "/env/lib/python3.5/site-packages/flask/app.py", line 1612, in full_dispatch_request
    rv = self.dispatch_request()
  File "/env/lib/python3.5/site-packages/flask/app.py", line 1598, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/vmagent/app/xxx.py", line 20, in simulate_error
    ec.report_exception()
  File "/env/lib/python3.5/site-packages/google/cloud/error_reporting/client.py", line 348, in report_exception
    user=user)
  File "/env/lib/python3.5/site-packages/google/cloud/error_reporting/client.py", line 277, in _send_error_report
    self.report_errors_api.report_error_event(error_report)
  File "/env/lib/python3.5/site-packages/google/cloud/error_reporting/client.py", line 162, in report_errors_api
    self._report_errors_api = make_report_error_api(self)
  File "/env/lib/python3.5/site-packages/google/cloud/error_reporting/_gax.py", line 44, in make_report_error_api
    return _ErrorReportingGaxApi(gax_client, client.project)
AttributeError: 'Client' object has no attribute 'project'

In the same project I'm also creating clients for pubsub and storage with the same default constructor and they both find the project and credentials, both when running in appengine as well as when I run the container locally and specify credentials by setting GOOGLE_APPLICATION_CREDENTIALS to point to a json file containing credentials for a service account.

I have also tried explicitly passing the project explicitly using something like:

ec = error_reporting.Client(project='xyz')

and

ec = error_reporting.Client('xyz')

to no avail.

Here is the sample code that fails:

from flask import Flask
from google.cloud import error_reporting


app = Flask(__name__)


@app.route('/simulate_error')
def simulate_error():
    ec = error_reporting.Client()
    try:
        # simulate calling a method that's not defined
        raise NameError
    except Exception:
        ec.report_exception()


if __name__ == '__main__':
    app.run(host='0.0.0.0', debug=True)

Here is the output from pip freeze | grep ^google-cloud:

google-cloud==0.23.0
google-cloud-bigquery==0.23.0
google-cloud-bigtable==0.23.1
google-cloud-core==0.23.1
google-cloud-datastore==0.23.0
google-cloud-dns==0.23.0
google-cloud-error-reporting==0.23.1
google-cloud-language==0.23.1
google-cloud-logging==0.23.1
google-cloud-monitoring==0.23.0
google-cloud-pubsub==0.23.0
google-cloud-resource-manager==0.23.0
google-cloud-runtimeconfig==0.23.0
google-cloud-spanner==0.23.1
google-cloud-speech==0.23.0
google-cloud-storage==0.23.1
google-cloud-translate==0.23.0
google-cloud-vision==0.23.3

Metadata

Metadata

Labels

api: clouderrorreportingIssues related to the Error Reporting API.priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions