Open hymvp opened 4 days ago
Hey @hymvp! I'm here to help you with your bug report. I can assist with bug fixes, answer questions, and guide you on becoming a contributor. Let's tackle this together while we wait for a human maintainer.
Ensure that the S3_BUCKET_NAME
configuration is correctly set in your application configuration. The S3Storage
class relies on this configuration, and if it is missing or incorrect, it can lead to errors during bucket name validation.
In your configuration file (which might be config.py
or another configuration source), you should have:
S3_BUCKET_NAME = 'your-bucket-name'
S3_SECRET_KEY = 'your-secret-key'
S3_ACCESS_KEY = 'your-access-key'
S3_ENDPOINT = 'your-endpoint-url'
S3_REGION = 'your-region'
S3_ADDRESS_STYLE = 'your-addressing-style'
Replace 'your-bucket-name'
, 'your-secret-key'
, 'your-access-key'
, 'your-endpoint-url'
, 'your-region'
, and 'your-addressing-style'
with the actual values for your S3 setup.
Additionally, ensure that the STORAGE_TYPE
in your application configuration is set to 's3'
:
STORAGE_TYPE = 's3'
This will ensure that the S3Storage
class is properly initialized and used for file storage operations [1][2].
To continue talking to Dosu, mention @dosu.
Link #5507 @bowenliang123 Could you take a look at this?
Hi @hymvp , could you have a try with #5590 manually in your code to see whether the problem still occurs?
also cc @takatost
hi @bowenliang123, i refer to https://github.com/langgenius/dify/pull/5590 modify app.py ,the problem still occurs
Then, #5590 is not relevant in your case. The configs for storage seems read from Flask app config not directly from the env vars.
Could you @hymvp
bucket
value where the exception thrown at "botocore/hooks.py" L278
Self Checks
Dify version
0.6.11
Cloud or Self Hosted
Cloud
Steps to reproduce
After my testing, deleting config.py may cause custom file storage errors (/api/extensions/storage) docker compose logs -f api api-1 | return self._emit(event_name, kwargs) api-1 | File "/app/api/.venv/lib/python3.10/site-packages/botocore/hooks.py", line 239, in _emit api-1 | response = handler(**kwargs) api-1 | File "/app/api/.venv/lib/python3.10/site-packages/botocore/handlers.py", line 278, in validate_bucket_name api-1 | if not VALID_BUCKET.search(bucket) and not VALID_S3_ARN.search(bucket): api-1 | TypeError: expected string or bytes-like object
✔️ Expected Behavior
Upload files to s3 bucket
❌ Actual Behavior
After my testing, deleting config.py may cause custom file storage errors (/api/extensions/storage) api-1 | return self._emit(event_name, kwargs) api-1 | File "/app/api/.venv/lib/python3.10/site-packages/botocore/hooks.py", line 239, in _emit api-1 | response = handler(**kwargs) api-1 | File "/app/api/.venv/lib/python3.10/site-packages/botocore/handlers.py", line 278, in validate_bucket_name api-1 | if not VALID_BUCKET.search(bucket) and not VALID_S3_ARN.search(bucket): api-1 | TypeError: expected string or bytes-like object