Skip to content

Incorrect logging level for oauth2client.contrib.locked_file (ref #427) #873

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
quasipedia opened this issue Apr 20, 2020 · 7 comments · Fixed by #1125
Closed

Incorrect logging level for oauth2client.contrib.locked_file (ref #427) #873

quasipedia opened this issue Apr 20, 2020 · 7 comments · Fixed by #1125
Assignees
Labels
type: docs Improvement to the documentation for an API.

Comments

@quasipedia
Copy link

This is - as per request in the original #427 - a follow-up issue.

The function documentation says:

Detects an appropriate cache module and returns it. Returns googleapiclient.discovery_cache.base.Cache, a cache object which is auto detected, or None if no cache object is available.

Exceptions in this context only provide a pythonic way to do control flow, and do not indicate anomalies or malfunctioning of the code. None is a perfectly fine, as-per-specifications behaviour. The correct level should probably be INFO.

Also, even if you would stand by the WARNING level, you should tidy up the messy log message. This is what the user is met with:

Traceback (most recent call last):
  File "/home/mac/dev/flashfaces/flashfaces/lib/python3.8/site-packages/googleapiclient/discovery_cache/__init__.py", line 36, in autodetect
    from google.appengine.api import memcache
ModuleNotFoundError: No module named 'google.appengine'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/mac/dev/flashfaces/flashfaces/lib/python3.8/site-packages/googleapiclient/discovery_cache/file_cache.py", line 33, in <module>
    from oauth2client.contrib.locked_file import LockedFile
ModuleNotFoundError: No module named 'oauth2client.contrib.locked_file'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/mac/dev/flashfaces/flashfaces/lib/python3.8/site-packages/googleapiclient/discovery_cache/file_cache.py", line 37, in <module>
    from oauth2client.locked_file import LockedFile
ModuleNotFoundError: No module named 'oauth2client.locked_file'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/mac/dev/flashfaces/flashfaces/lib/python3.8/site-packages/googleapiclient/discovery_cache/__init__.py", line 42, in autodetect
    from . import file_cache
  File "/home/mac/dev/flashfaces/flashfaces/lib/python3.8/site-packages/googleapiclient/discovery_cache/file_cache.py", line 40, in <module>
    raise ImportError(
ImportError: file_cache is unavailable when using oauth2client >= 4.0.0 or google-auth

A saner way to to communicate with the user could potentially be:

WARNING - No caching available (file_cache is unavailable when using oauth2client >= 4.0.0 or google-auth)

@yoshi-automation yoshi-automation added the triage me I really want to be triaged. label Apr 21, 2020
@busunkim96 busunkim96 added type: docs Improvement to the documentation for an API. and removed triage me I really want to be triaged. labels Apr 21, 2020
@qxcv
Copy link

qxcv commented Sep 10, 2020

Simply removing exc_info=True from this line would suffice (I made a fork just to do this).

qxcv added a commit to qxcv/google-api-python-client that referenced this issue Sep 10, 2020
@davidcpell
Copy link

davidcpell commented Sep 21, 2020

Same/similar issue here.

Getting the following when instantiating a Google Drive client:

WARNING:googleapiclient.discovery_cache:file_cache is unavailable when using oauth2client >= 4.0.0 or google-auth
Traceback (most recent call last):
  File "/Users/dpell/src/.../.venv/lib/python3.8/site-packages/googleapiclient/discovery_cache/file_cache.py", line 33, in <module>
    from oauth2client.contrib.locked_file import LockedFile
ModuleNotFoundError: No module named 'oauth2client.contrib.locked_file'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/dpell/src/.../.venv/lib/python3.8/site-packages/googleapiclient/discovery_cache/file_cache.py", line 37, in <module>
    from oauth2client.locked_file import LockedFile
ModuleNotFoundError: No module named 'oauth2client.locked_file'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/dpell/src/.../.venv/lib/python3.8/site-packages/googleapiclient/discovery_cache/__init__.py", line 44, in autodetect
    from . import file_cache
  File "/Users/dpell/src/.../.venv/lib/python3.8/site-packages/googleapiclient/discovery_cache/file_cache.py", line 40, in <module>
    raise ImportError(
ImportError: file_cache is unavailable when using oauth2client >= 4.0.0 or google-auth
WARNING:googleapiclient.discovery_cache:file_cache is unavailable when using oauth2client >= 4.0.0 or google-auth
Traceback (most recent call last):
  File "/Users/dpell/src/.../.venv/lib/python3.8/site-packages/googleapiclient/discovery_cache/file_cache.py", line 33, in <module>
    from oauth2client.contrib.locked_file import LockedFile
ModuleNotFoundError: No module named 'oauth2client.contrib.locked_file'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/dpell/src/.../.venv/lib/python3.8/site-packages/googleapiclient/discovery_cache/file_cache.py", line 37, in <module>
    from oauth2client.locked_file import LockedFile
ModuleNotFoundError: No module named 'oauth2client.locked_file'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/dpell/src/.../.venv/lib/python3.8/site-packages/googleapiclient/discovery_cache/__init__.py", line 44, in autodetect
    from . import file_cache
  File "/Users/dpell/src/.../.venv/lib/python3.8/site-packages/googleapiclient/discovery_cache/file_cache.py", line 40, in <module>
    raise ImportError(
ImportError: file_cache is unavailable when using oauth2client >= 4.0.0 or google-auth

This is causing issues in our monitoring stack because we consider logs with 'Traceback' in them to be unhandled exceptions and this warning message results in false positives.

So far my solution has been to lock oauth2client under 1.5.2, which is what I get when specifying < 4.0.0 in my requirements.txt.

@mohkale
Copy link

mohkale commented Oct 30, 2020

Any idea when this might be merged?

The log output takes up way too much space and occurs way too frequently (every search causes it to be repeated), which just makes logs a chore to go through. I can understand showing all of this in the first search but repeating it every time is just annoying.

@rveeravalli
Copy link

rveeravalli commented Nov 2, 2020

I've used the method proposed by @davidcpell to lower the oauth2client to 1.5.2, which works well. However, an exception is generated if I have logging turned on in our code when using the latest version of the oauth2client.
Any idea when this is likely to fixed?

@mysticaltech
Copy link

This fixed my issue https://stackoverflow.com/questions/40154672/importerror-file-cache-is-unavailable-when-using-python-client-for-google-ser

@rveeravalli
Copy link

@mysticaltech Thank you. That worked well!

@parthea
Copy link
Contributor

parthea commented Nov 26, 2020

Linking #1061 as it is related.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
type: docs Improvement to the documentation for an API.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants