pluginupdate: fix AttributeError when handling HTTPResponse objects

Fix an issue in the vim-plugins-updater where it was trying to access the

'normalized_name' attribute on an HTTPResponse object, causing the updater

to crash with:

AttributeError: 'HTTPResponse' object has no attribute 'normalized_name'

The fix adds type checking to ensure we only access normalized_name on

Plugin objects, and properly handle other types like Exceptions and

HTTPResponse objects.

Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
This commit is contained in:
Austin Horstman 2025-05-10 13:08:23 -05:00
parent 9831a2b6c3
commit 31bc320fd1
No known key found for this signature in database

View file

@ -558,7 +558,16 @@ class Editor:
}
for plugin_desc, plugin, redirect in fetched:
result[plugin.normalized_name] = (plugin_desc, plugin, redirect)
# Check if plugin is a Plugin object and has normalized_name attribute
if isinstance(plugin, Plugin) and hasattr(plugin, 'normalized_name'):
result[plugin.normalized_name] = (plugin_desc, plugin, redirect)
elif isinstance(plugin, Exception):
# For exceptions, we can't determine the normalized_name
# Just log the error and continue
log.error(f"Error fetching plugin {plugin_desc.name}: {plugin!r}")
else:
# For unexpected types, log the issue
log.error(f"Unexpected plugin type for {plugin_desc.name}: {type(plugin)}")
return list(result.values())