Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ParamValidationError for invalid bucket name when Config.parameter_validation is False #3234

Open
cbodley opened this issue Aug 8, 2024 · 4 comments
Labels
feature-request This issue requests a feature. p2 This is a standard priority issue s3

Comments

@cbodley
Copy link

cbodley commented Aug 8, 2024

Describe the bug

Setting parameter_validation=False in botocore.config.Config does not disable validation of bucket names.

Expected Behavior

expected boto to issue the request with the given bucket name

Current Behavior

client.create_bucket(Bucket='test;bucket') raises botocore.exceptions.ParamValidationError:

Traceback (most recent call last):
  File "/home/cbodley/test.py", line 9, in <module>
    client.create_bucket(Bucket='test;bucket')
  File "/usr/lib/python3.12/site-packages/botocore/client.py", line 565, in _api_call
    return self._make_api_call(operation_name, kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/botocore/client.py", line 958, in _make_api_call
    api_params = self._emit_api_params(
                 ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/botocore/client.py", line 1077, in _emit_api_params
    self.meta.events.emit(
  File "/usr/lib/python3.12/site-packages/botocore/hooks.py", line 412, in emit
    return self._emitter.emit(aliased_event_name, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/botocore/hooks.py", line 256, in emit
    return self._emit(event_name, kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/botocore/hooks.py", line 239, in _emit
    response = handler(**kwargs)
               ^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/botocore/handlers.py", line 287, in validate_bucket_name
    raise ParamValidationError(report=error_msg)
botocore.exceptions.ParamValidationError: Parameter validation failed:
Invalid bucket name "test;bucket": Bucket name must match the regex "^[a-zA-Z0-9.\-_]{1,255}$" or be an ARN matching the regex "^arn:(aws).*:(s3|s3-object-lambda):[a-z\-0-9]*:[0-9]{12}:accesspoint[/:][a-zA-Z0-9\-.]{1,63}$|^arn:(aws).*:s3-outposts:[a-z\-0-9]+:[0-9]{12}:outpost[/:][a-zA-Z0-9\-]{1,63}[/:]accesspoint[/:][a-zA-Z0-9\-]{1,63}$"

Reproduction Steps

import botocore
import boto3

cfg = botocore.config.Config(parameter_validation=False,
                             s3={"addressing_style": "path"})
client = boto3.client(service_name='s3',
                      endpoint_url='http://localhost:8000',
                      config=cfg)
client.create_bucket(Bucket='test;bucket')

Possible Solution

avoid calling validate_bucket_name() when Config.parameter_validation is False

Additional Information/Context

testing against s3-compatible Ceph server which optionally supports 'relaxed' bucket naming requirements

SDK version used

1.34.153

Environment details (OS name and version, etc.)

Fedora 40, python 3.12

@cbodley cbodley added bug This issue is a confirmed bug. needs-triage This issue or PR still needs to be triaged. labels Aug 8, 2024
@tim-finnigan tim-finnigan self-assigned this Aug 12, 2024
@tim-finnigan
Copy link
Contributor

Thanks for reaching out. This came up before in the Boto3 repo: boto/boto3#2891

As mentioned there:

Unfortunately the parameter validation flag unfortunately does not apply to S3 validation. Those validators are part of a customization. If you can provide more details on what your use case would be, we can discuss if this is a useful feature request for others as well.

@tim-finnigan tim-finnigan added response-requested Waiting on additional info and feedback. s3 p2 This is a standard priority issue and removed needs-triage This issue or PR still needs to be triaged. labels Aug 12, 2024
Copy link

Greetings! It looks like this issue hasn’t been active in longer than five days. We encourage you to check if this is still an issue in the latest release. In the absence of more information, we will be closing this issue soon. If you find that this is still a problem, please feel free to provide a comment or upvote with a reaction on the initial post to prevent automatic closure. If the issue is already closed, please feel free to open a new one.

@timj
Copy link

timj commented Aug 26, 2024

How do we disable bucket name validation then? Our Ceph buckets are of the form "x:y" and we currently have to disable the checks by doing:

>>> from botocore.handlers import validate_bucket_name
>>> client.meta.events.unregister("before-parameter-build.s3", validate_bucket_name)

but this can't be done if we are using s3fs where the client object is internal and whose creation is deferred until needed.

See fsspec/s3fs#893

@github-actions github-actions bot removed closing-soon response-requested Waiting on additional info and feedback. labels Aug 27, 2024
@tim-finnigan tim-finnigan added the needs-review This issue or pull request needs review from a core team member. label Sep 5, 2024
@tim-finnigan
Copy link
Contributor

Converting to a feature request — not sure if there's a good workaround for third-party use cases here.

@tim-finnigan tim-finnigan added feature-request This issue requests a feature. and removed bug This issue is a confirmed bug. needs-review This issue or pull request needs review from a core team member. labels Sep 5, 2024
@tim-finnigan tim-finnigan removed their assignment Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request This issue requests a feature. p2 This is a standard priority issue s3
Projects
None yet
Development

No branches or pull requests

3 participants