Fix #241: 500 Error when submitting extension without "type" #242

Merged
Dalai Felinto merged 3 commits from fix-241-missing-type into main 2024-08-29 13:03:57 +02:00
Showing only changes of commit e6d3b9976a - Show all commits

View File

@ -21,7 +21,13 @@ import clamd
import magic import magic
import requests import requests
from constants.base import THUMBNAIL_FORMAT, THUMBNAIL_SIZES, THUMBNAIL_QUALITY from constants.base import (
EXTENSION_TYPE_CHOICES,
EXTENSION_TYPE_SLUGS_SINGULAR,
THUMBNAIL_FORMAT,
THUMBNAIL_SIZES,
THUMBNAIL_QUALITY,
)
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
FORBIDDEN_FILEPATHS = [ FORBIDDEN_FILEPATHS = [
@ -201,13 +207,13 @@ def validate_file_list(toml_content, manifest_filepath, file_list):
} }
) )
type_slug = toml_content['type'] type_slug = toml_content['type']
if type_slug == 'theme': if type_slug == EXTENSION_TYPE_SLUGS_SINGULAR[EXTENSION_TYPE_CHOICES.THEME]:
theme_xmls = filter_paths_by_ext(file_list, '.xml') theme_xmls = filter_paths_by_ext(file_list, '.xml')
# Special treatment for Mac, so the same problem (__MACOSX folders) # Special treatment for Mac, so the same problem (__MACOSX folders)
# doesn't lead to two errors showing. # doesn't lead to two errors showing.
if len(list(theme_xmls)) != 1 and '__MACOSX/' not in found_forbidden_filepaths: if len(list(theme_xmls)) != 1 and '__MACOSX/' not in found_forbidden_filepaths:
error_codes.append('missing_or_multiple_theme_xml') error_codes.append('missing_or_multiple_theme_xml')
elif type_slug == 'add-on': elif type_slug == EXTENSION_TYPE_SLUGS_SINGULAR[EXTENSION_TYPE_CHOICES.BPY]:
# __init__.py is expected to be next to the manifest # __init__.py is expected to be next to the manifest
expected_init_path = _canonical_path('__init__.py', manifest_filepath) expected_init_path = _canonical_path('__init__.py', manifest_filepath)
init_filepath = find_exact_path(file_list, expected_init_path) init_filepath = find_exact_path(file_list, expected_init_path)