{"record":{"id":"c34593cfc6e864c8","repo":"opendatalab/MinerU","slug":"default-prefix-must-be-provided","errorCode":null,"errorMessage":"default_prefix must be provided","messagePattern":"default_prefix must be provided","errorType":"validation","errorClass":"InvalidConfig","httpStatus":null,"severity":"error","filePath":"mineru/data/data_reader_writer/multi_bucket_s3.py","lineNumber":35,"sourceCode":"\n    return S3Reader, S3Writer\n\n\nclass MultiS3Mixin:\n    def __init__(self, default_prefix: str, s3_configs: list[S3Config]):\n        \"\"\"Initialized with multiple s3 configs.\n\n        Args:\n            default_prefix (str): the default prefix of the relative path. for example, {some_bucket}/{some_prefix} or {some_bucket}\n            s3_configs (list[S3Config]): list of s3 configs, the bucket_name must be unique in the list.\n\n        Raises:\n            InvalidConfig: default bucket config not in s3_configs.\n            InvalidConfig: bucket name not unique in s3_configs.\n            InvalidConfig: default bucket must be provided.\n        \"\"\"\n        if len(default_prefix) == 0:\n            raise InvalidConfig('default_prefix must be provided')\n\n        arr = default_prefix.strip('/').split('/')\n        self.default_bucket = arr[0]\n        self.default_prefix = '/'.join(arr[1:])\n\n        found_default_bucket_config = False\n        for conf in s3_configs:\n            if conf.bucket_name == self.default_bucket:\n                found_default_bucket_config = True\n                break\n\n        if not found_default_bucket_config:\n            raise InvalidConfig(\n                f'default_bucket: {self.default_bucket} config must be provided in s3_configs: {s3_configs}'\n            )\n\n        uniq_bucket = set([conf.bucket_name for conf in s3_configs])\n        if len(uniq_bucket) != len(s3_configs):","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/opendatalab/MinerU/blob/4fe4bde114a23ee5dd637eae99b767f4669bf58c/mineru/data/data_reader_writer/multi_bucket_s3.py#L17-L53","documentation":"MultiBucketS3Mixin.__init__ raises InvalidConfig when default_prefix is an empty string (`len(default_prefix) == 0`). The first path segment of default_prefix becomes self.default_bucket, so an empty prefix leaves the mixin without a default bucket and the constructor refuses to continue.","triggerScenarios":"Calling MultiBucketS3DataReader('' , configs) or MultiBucketS3DataWriter('', configs); also passing a whitespace-only string (len check does not strip first, though strip('/') happens after).","commonSituations":"default_prefix built dynamically from an env var or config key that is unset/empty; template strings like f'{bucket}/{prefix}' where both parts are empty; misconfigured pipeline YAML.","solutions":["Pass a non-empty default_prefix of the form '{bucket}' or '{bucket}/{prefix}', e.g. 'my-bucket' or 'my-bucket/docs'.","Check the code that produces default_prefix (env var, CLI arg, config file) and supply a real bucket name.","Add a startup assertion so an empty prefix fails with your own message instead of the library's."],"exampleFix":"# before\nreader = MultiBucketS3DataReader('', s3_configs)\n\n# after\nreader = MultiBucketS3DataReader('my-bucket/pdfs', s3_configs)","handlingStrategy":"validation","validationCode":"def make_s3_reader(default_prefix: str, configs: list):\n    if not default_prefix or not default_prefix.strip('/'):\n        raise ValueError('default_prefix must be like \"{bucket}\" or \"{bucket}/{prefix}\"')\n    return MultiBucketS3DataReader(default_prefix, configs)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Assert default_prefix is non-empty at config-load time with a domain-specific message.","Derive default_prefix from the same config block as the bucket list so it cannot drift to empty.","Unit-test config parsing for empty env vars before they reach library constructors."],"tags":["s3","config","validation","constructor"],"backgroundTag":null,"analyzedSha":"4fe4bde114a23ee5dd637eae99b767f4669bf58c","analyzedAt":"2026-08-14T21:29:18.456Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}