Skip to content

Catch key, index and type error when getting scan results#19956

Merged
SaschaCowley merged 1 commit into
betafrom
fix-addonstore
Apr 16, 2026
Merged

Catch key, index and type error when getting scan results#19956
SaschaCowley merged 1 commit into
betafrom
fix-addonstore

Conversation

@SaschaCowley
Copy link
Copy Markdown
Member

Link to issue number:

Fixes #19952

Summary of the issue:

The add-on store fails to load if invalid data is returned from the server.

Description of user facing changes:

Crash no-longer occurs.

Description of developer facing changes:

None.

Description of development approach:

When extracting scan results, catch TypeError and IndexError as well as KeyError.

Testing strategy:

Created a faulty cache:

jq `
'.data|=(fromjson|.[0].scanResults.virusTotal|=null|tostring)' `
_cachedCompatibleAddons.old.json > _cachedCompatibleAddons.json 

Ran from source and checked that the add-on store opened.

Known issues with pull request:

In my testing, the invalid file also caused NVDA not to start, but the OP didn't report any such problem, so their problem may have been slightly different? Nevertheless this fix solves an actual bug.

Code Review Checklist:

  • Documentation:
    • Change log entry
    • User Documentation
    • Developer / Technical Documentation
    • Context sensitive help for GUI changes
  • Testing:
    • Unit tests
    • System (end to end) tests
    • Manual testing
  • UX of all users considered:
    • Speech
    • Braille
    • Low Vision
    • Different web browsers
    • Localization in other languages / culture than English
  • API is compatible with existing add-ons.
  • Security precautions taken.

@SaschaCowley SaschaCowley requested a review from a team as a code owner April 16, 2026 03:41
@SaschaCowley SaschaCowley requested a review from seanbudd April 16, 2026 03:41
@seanbudd seanbudd added this to the 2026.1 milestone Apr 16, 2026
@SaschaCowley SaschaCowley enabled auto-merge (squash) April 16, 2026 03:52
@SaschaCowley SaschaCowley merged commit 888f834 into beta Apr 16, 2026
39 checks passed
@SaschaCowley SaschaCowley deleted the fix-addonstore branch April 16, 2026 04:13
@XLTechie
Copy link
Copy Markdown
Collaborator

XLTechie commented Apr 16, 2026 via email

@CyrilleB79
Copy link
Copy Markdown
Contributor

Trying from last beta branch version (commit 3d07d82) from source, I can open the Store, but NVDA still logs an error each time; and even a lot of time when you open the available add-ons list.

Here is the error, taken from a brand new empty config, and after having installed only one add-on.

ERROR - addonStore.models.scanResults.VirusTotalScanResults.fromDict (10:20:19.791) - MainThread (14104):
Malformed add-on scan results.: {'addonId': 'resourceMonitor', 'displayName': 'Resource Monitor', 'description': "Un superviseur de resources clés en mains pour rapporter la charge moyenne du processeur, l'utilisation de la mémoire, l'état d'utilisation des disques et de la batterie ainsi que d'autres informations.", 'publisher': 'josephsl', 'addonVersionName': '26.04.100', 'channel': 'beta', 'homepage': 'https://github.com/kefaslungu/resourceMonitor', 'changelog': '* NVDA 2025.3.2 or later is required.\n* NVDA will announce Windows Server releases using standardized release name instead of dedicated server release name e.g. Windows Server 24H2 instead of Windows Server 2025.\n* NVDA will no longer add "0 minutes" to battery status (example: 4 hours instead of 4 hours, 0 minutes).\n* NVDA will recognize additional prefixes for larger memory and storage sizes including ronnabyte (1000 to the power of 9) and quettabyte (1000 to the power of 10).', 'license': 'GPL v2', 'licenseURL': 'https://www.gnu.org/licenses/gpl-2.0.html', 'sourceURL': 'https://github.com/kefaslungu/resourceMonitor', 'URL': 'https://github.com/kefaslungu/resourceMonitor/releases/download/26.01/resourceMonitor-26.04.100.nvda-addon', 'sha256': '2a83b713e38596cfbcb3f98b5eb91530ddfd0e9319907c6119cbbbe08f7acc88', 'addonVersionNumber': {'major': 26, 'minor': 4, 'patch': 100}, 'minNVDAVersion': {'major': 2025, 'minor': 3, 'patch': 2}, 'lastTestedVersion': {'major': 2026, 'minor': 1, 'patch': 0}, 'reviewURL': 'https://github.com/nvaccess/addon-datastore/discussions/2031', 'submissionTime': 1775445190000, 'legacy': False, 'scanResults': {'scanUrl': 'https://www.virustotal.com/gui/file/2a83b713e38596cfbcb3f98b5eb91530ddfd0e9319907c6119cbbbe08f7acc88', 'malicious': 0, 'undetected': 67, 'harmless': 0, 'suspicious': 0, 'failure': 0, 'timeout': 0, 'confirmedTimeout': 0, 'typeUnsupported': 9}}
Traceback (most recent call last):
  File "addonStore\models\scanResults.py", line 31, in fromDict
    analysisStats = scanResults["virusTotal"][0]["last_analysis_stats"]
                    ~~~~~~~~~~~^^^^^^^^^^^^^^
KeyError: 'virusTotal'

From this error, it's quite obvious that it's not a matter of corrupted or badly transferred file.

@SaschaCowley or @seanbudd, could you have a look? Even if the Store now opens, it's quite ugly to ship with such a systematic error logged.

You can reproduce with last beta branch, empty new config folder, install an add-on, restart and open the Add-on Store again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants