{"record":{"id":"396b264cdee4478c","repo":"mlflow/mlflow","slug":"not-an-s3-uri-uri","errorCode":null,"errorMessage":"Not an S3 URI: {uri}","messagePattern":"Not an S3 URI: (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"mlflow/store/artifact/optimized_s3_artifact_repo.py","lineNumber":156,"sourceCode":"                \"(e.g., os.environ['AWS_DEFAULT_REGION'] = 'us-gov-west-1')\",\n                error_code=INVALID_PARAMETER_VALUE,\n            ) from error\n\n    def _get_s3_client(self):\n        return _get_s3_client(\n            addressing_style=self._addressing_style,\n            access_key_id=self._access_key_id,\n            secret_access_key=self._secret_access_key,\n            session_token=self._session_token,\n            region_name=self._region_name,\n            s3_endpoint_url=self._s3_endpoint_url,\n        )\n\n    def parse_s3_compliant_uri(self, uri):\n        \"\"\"Parse an S3 URI, returning (bucket, path)\"\"\"\n        parsed = urllib.parse.urlparse(uri)\n        if parsed.scheme != \"s3\":\n            raise Exception(f\"Not an S3 URI: {uri}\")\n        path = parsed.path\n        path = path.removeprefix(\"/\")\n        return parsed.netloc, path\n\n    @staticmethod\n    def get_s3_file_upload_extra_args():\n        if s3_file_upload_extra_args := MLFLOW_S3_UPLOAD_EXTRA_ARGS.get():\n            return json.loads(s3_file_upload_extra_args)\n        else:\n            return None\n\n    def _upload_file(self, s3_client, local_file, bucket, key):\n        extra_args = {}\n        extra_args.update(self._s3_upload_extra_args)\n        guessed_type, guessed_encoding = guess_type(local_file)\n        if guessed_type is not None:\n            extra_args[\"ContentType\"] = guessed_type\n        if guessed_encoding is not None:","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/mlflow/mlflow/blob/6a27f2decc0b76eb1b54af31849784addb357dbc/mlflow/store/artifact/optimized_s3_artifact_repo.py#L138-L174","documentation":"parse_s3_compliant_uri on OptimizedS3ArtifactRepository only accepts URIs whose scheme is exactly 's3'; anything else raises a plain Exception. It is invoked from the constructor, so a bad URI fails at repo creation time.","triggerScenarios":"Passing a URI like 's3a://bucket/key', 'file:///path', or an https URL into OptimizedS3ArtifactRepository (directly or via code that assumes S3).","commonSituations":"Using s3a:// (Spark-style) or S3 endpoints with custom schemes; string concatenation bugs producing malformed URIs; routing non-S3 artifact URIs into the optimized S3 repo.","solutions":["Convert the URI to s3:// form: replace the scheme, keeping bucket and key (s3a://bucket/path -> s3://bucket/path).","Ensure you are constructing the correct repo class for the scheme (e.g., LocalArtifactRepository for file:, R2ArtifactRepository for r2:).","Validate the URI scheme before constructing the repo.","Fix string-building bugs that drop or mangle the scheme."],"exampleFix":"// before\nrepo = OptimizedS3ArtifactRepository(\"s3a://my-bucket/model\")\n# after\nuri = \"s3a://my-bucket/model\".replace(\"s3a://\", \"s3://\", 1)\nrepo = OptimizedS3ArtifactRepository(uri)","handlingStrategy":"validation","validationCode":"from urllib.parse import urlparse\ndef ensure_s3_uri(uri: str) -> str:\n    if urlparse(uri).scheme != \"s3\":\n        raise ValueError(f\"Expected s3:// URI, got: {uri}\")\n    return uri\nensure_s3_uri(uri)  # call before constructing the repo","typeGuard":"def is_s3_uri(uri: str) -> bool:\n    from urllib.parse import urlparse\n    return urlparse(uri).scheme == \"s3\"","tryCatchPattern":"try:\n    repo = OptimizedS3ArtifactRepository(uri)\nexcept Exception as e:\n    if str(e).startswith(\"Not an S3 URI\"):\n        repo = get_artifact_repository(uri)  # route by scheme\n    else:\n        raise","preventionTips":["Normalize s3a:///other schemes to s3:// before artifact-repo calls","Use mlflow.artifacts utilities rather than instantiating repo classes directly with raw URIs","Unit-test URI builders to assert scheme == 's3'"],"tags":["s3","uri","validation","scheme"],"backgroundTag":"invalid-uri-scheme","analyzedSha":"6a27f2decc0b76eb1b54af31849784addb357dbc","analyzedAt":"2026-08-29T20:54:51.419Z","schemaVersion":2},"datasetVersion":"2026-08-29T22:17:34.462Z"}