Skip to content

Commit 375414a

Browse files
authored
fix: Move the AWS_NORMALIZER config to top-level configuration list (#316)
The `AWS_NORMALIZER` configuration is used for both the storage and result storage modules, but there's no requirement to use the storage module if you only need the result storage module. In that case, you might have the storage module configured with: ``` STORAGE = "thumbor.storages.no_storage" ``` In that case, the `thumbor_aws.storage` file is never loaded, which means the `AWS_NORMALIZER` configuration never gets defined, which in turn means any requests for the result storage module which tries to call `normalize_path` will fail with an error like this: ``` 2025-08-26 08:08:38 thumbor:ERROR [BaseHander.execute_image_operations] AWS_NORMALIZER Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/thumbor/handlers/__init__.py", line 145, in execute_image_operations result = await self.context.modules.result_storage.get() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/thumbor_aws/result_storage.py", line 168, in get file_abspath = normalize_path(self.context, self.prefix, path) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/thumbor_aws/utils.py", line 9, in normalize_path new_path = context.config.AWS_NORMALIZER(path) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/derpconf/config.py", line 225, in __getattr__ raise AttributeError(name) AttributeError: AWS_NORMALIZER ``` This fixes that by moving the configuration setting to the top-level config file to make sure it's always defined, regardless of if `thumbor_aws.storage` is used or not.
1 parent 027d11c commit 375414a

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

thumbor_aws/config.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
# http://www.opensource.org/licenses/mit-license
99
# Copyright (c) 2021 Bernardo Heynemann heynemann@gmail.com
1010

11+
from urllib.parse import unquote
1112

1213
from thumbor.config import Config, config
1314

@@ -124,6 +125,13 @@
124125
"tc_aws Compatibility",
125126
)
126127

128+
Config.define(
129+
"AWS_NORMALIZER",
130+
lambda path: unquote(path).lstrip("/"),
131+
"How to normalize storage paths before adding the prefix",
132+
"AWS Storage",
133+
)
134+
127135

128136
def __generate_config():
129137
config.generate_config()

thumbor_aws/storage.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
from json import dumps, loads
1212
from typing import Any
13-
from urllib.parse import unquote
1413

1514
from thumbor import storages
1615
from thumbor.engines import BaseEngine
@@ -70,13 +69,6 @@
7069
"AWS Storage",
7170
)
7271

73-
Config.define(
74-
"AWS_NORMALIZER",
75-
lambda path: unquote(path).lstrip("/"),
76-
"How to normalize storage paths before adding the prefix",
77-
"AWS Storage",
78-
)
79-
8072

8173
class Storage(storages.BaseStorage, S3Client):
8274
def __init__(self, context):

0 commit comments

Comments
 (0)