sonatype-nexus-community/ossindex-python

[BUG] Caching of OSS Index Responses can lead to exceptions?

madpah opened this issue · 2 comments

Raised from sonatype-nexus-community/jake#71.

Describe the bug

When invoking jake with ddt, exceptions can be seen when not adding the flag --clear-cache.

~/data/work/SoftFormance/gryps-project │ on master !1 ▓▒░ jake ddt                                                                                                                  ░▒▓ ✔ │ gryps-project   │ 2.6.6   │ at 12:55:03 
                   ___           ___           ___     
       ___        /  /\         /  /\         /  /\    
      /__/\      /  /::\       /  /:/        /  /::\   
      \__\:\    /  /:/\:\     /  /:/        /  /:/\:\  
  ___ /  /::\  /  /::\ \:\   /  /::\____   /  /::\ \:\ 
 /__/\  /:/\/ /__/:/\:\_\:\ /__/:/\:::::\ /__/:/\:\ \:\
 \  \:\/:/~~  \__\/  \:\/:/ \__\/~|:|~~~~ \  \:\ \:\_\/
  \  \::/          \__\::/     |  |:|      \  \:\ \:\  
   \__\/           /  /:/      |  |:|       \  \:\_\/  
                  /__/:/       |__|:|        \  \:\    
                  \__\/         \__\|         \__\/    

                                                  
            /)                     /)             
        _/_(/    _     _  __   _  (/_   _         
 o   o  (__/ )__(/_   /_)_/ (_(_(_/(___(/_ o   o  
                                                  
                                                  

Jake Version: 1.2.2
Put your Python dependencies in a chokehold

🐍 Collected 335 packages from your environment ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% -:--:--
Querying OSS Index for details on your packages ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━  30% -:--:--
Sanity checking...                              ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━   0% -:--:--
Traceback (most recent call last):
  File "/home/dmytro/.virtualenvs/gryps-project/bin/jake", line 8, in <module>
    sys.exit(main())
  File "/home/dmytro/.virtualenvs/gryps-project/lib/python3.8/site-packages/jake/app.py", line 124, in main
    JakeCmd().execute()
  File "/home/dmytro/.virtualenvs/gryps-project/lib/python3.8/site-packages/jake/app.py", line 70, in execute
    exit_code: int = command.execute(arguments=self._arguments)
  File "/home/dmytro/.virtualenvs/gryps-project/lib/python3.8/site-packages/jake/command/__init__.py", line 33, in execute
    return self.handle_args()
  File "/home/dmytro/.virtualenvs/gryps-project/lib/python3.8/site-packages/jake/command/oss.py", line 76, in handle_args
    oss_index_results = oss.get_component_report(
  File "/home/dmytro/.virtualenvs/gryps-project/lib/python3.8/site-packages/ossindex/ossindex.py", line 59, in get_component_report
    return self._get_results(packages=packages)
  File "/home/dmytro/.virtualenvs/gryps-project/lib/python3.8/site-packages/ossindex/ossindex.py", line 146, in _get_results
    results = results + self._make_oss_index_component_report_call(packages=chunk)
  File "/home/dmytro/.virtualenvs/gryps-project/lib/python3.8/site-packages/ossindex/ossindex.py", line 163, in _make_oss_index_component_report_call
    self._upsert_cache_with_oss_index_responses(oss_components=results)
  File "/home/dmytro/.virtualenvs/gryps-project/lib/python3.8/site-packages/ossindex/ossindex.py", line 187, in _upsert_cache_with_oss_index_responses
    self._cache_database.update({
  File "/home/dmytro/.virtualenvs/gryps-project/lib/python3.8/site-packages/tinydb/table.py", line 369, in update
    self._update_table(updater)
  File "/home/dmytro/.virtualenvs/gryps-project/lib/python3.8/site-packages/tinydb/table.py", line 709, in _update_table
    updater(table)
  File "/home/dmytro/.virtualenvs/gryps-project/lib/python3.8/site-packages/tinydb/table.py", line 361, in updater
    if _cond(table[doc_id]):
TypeError: 'int' object is not callable

To Reproduce
Steps to reproduce the behaviour:

As above.

Expected behaviour
Caching should not cause Exceptions in any circumstance. If the cache has expired, or is invalid for some reason, it should automatically be cleared and re-generated.

I'm seeing this too in v1.2.3. TypeError: 'int' object is not callable - because I can't have this intermittently stopping a build to pass, I'm going to have to run clear cache before each invocation.