Commit a697a7d
fix: handle S3 key length limits by hashing long collection/key names
S3 has a maximum key length of 1024 bytes. This fix ensures that long
collection or key names are automatically hashed when they exceed safe
limits (500 bytes each), keeping the total S3 key under 1024 bytes
while maintaining uniqueness through hash suffixes.
- Import hash_excess_length utility from key_value.shared.utils.sanitize
- Add MAX_COLLECTION_LENGTH and MAX_KEY_LENGTH constants (500 bytes each)
- Update _get_s3_key() to hash collection and key names if they exceed limits
- Follows the same pattern used by MongoDB store for handling long names
Fixes test_long_collection_name test which was failing with KeyTooLongError.
Co-authored-by: William Easton <strawgate@users.noreply.github.com>1 parent e78fded commit a697a7d
File tree
1 file changed
+15
-1
lines changed- key-value/key-value-aio/src/key_value/aio/stores/s3
1 file changed
+15
-1
lines changedLines changed: 15 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
15 | 22 | | |
16 | 23 | | |
17 | 24 | | |
| |||
206 | 213 | | |
207 | 214 | | |
208 | 215 | | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
209 | 219 | | |
210 | 220 | | |
211 | 221 | | |
212 | 222 | | |
213 | 223 | | |
214 | 224 | | |
215 | 225 | | |
216 | | - | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
217 | 231 | | |
218 | 232 | | |
219 | 233 | | |
| |||
0 commit comments