question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:13
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
davidcpellcommented, 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.

1reaction
rveeravallicommented, Nov 19, 2020

@mysticaltech Thank you. That worked well!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Changing the Logging Level in a Logging Properties File - IBM
Navigate to the install_dir/conf directory. Do one of the following: Open the conf/log4j2.xml file to modify logging for the server. Open ...
Read more >
Spring Boot: How can I set the logging level with application ...
For the record, another option is to set the log level as environment variable, for example via the heroku dashboard. In Settings ->...
Read more >
Changing the GroupWise Admin Console Logging Level
To troubleshoot issues related to the GroupWise Admin Console, we need to change the log level to 'DEBUG' mode in order to get...
Read more >
logging — Logging facility for Python — Python 3.11.1 ...
Loggers have the following attributes and methods. Note that Loggers should NEVER be instantiated directly, but always through the module-level function logging ......
Read more >
Change logging levels in Jira Server - Atlassian Documentation
Purpose. The purpose of this article is to show how you can set the logging level for a package in Jira. Solution. Use...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found