We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Provide better error message for invalid endpoint urls
The error message could provide more context about what exactly went wrong with the request.  For example:

```
$ aws s3api list-buckets --endpoint-url example.com

Invalid URL u'/': No schema supplied
```

A better error message would be something like:

```
$ aws s3api list-buckets --endpoint-url example.com

Bad value for --endpoint-url "example.com": scheme is missing.  Must be of the form http://<hostname>/ or https://<hostname>/
```


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `awscli/compat.py`
Content:
```
1 # Copyright 2012-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2 
3 # Licensed under the Apache License, Version 2.0 (the "License"). You
4 # may not use this file except in compliance with the License. A copy of
5 # the License is located at
6 
7 #     http://aws.amazon.com/apache2.0/
8 
9 # or in the "license" file accompanying this file. This file is
10 # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11 # ANY KIND, either express or implied. See the License for the specific
12 # language governing permissions and limitations under the License.
13 import sys
14 import six
15 
16 if six.PY3:
17     import locale
18 
19     def get_stdout_text_writer():
20         return sys.stdout
21 
22     def compat_open(filename, mode='r', encoding=None):
23         """Back-port open() that accepts an encoding argument.
24 
25         In python3 this uses the built in open() and in python2 this
26         uses the io.open() function.
27 
28         If the file is not being opened in binary mode, then we'll
29         use locale.getpreferredencoding() to find the preferred
30         encoding.
31 
32         """
33         if 'b' not in mode:
34             encoding = locale.getpreferredencoding()
35         return open(filename, mode, encoding=encoding)
36 
37 else:
38     import codecs
39     import locale
40     import io
41 
42     def get_stdout_text_writer():
43         # In python3, all the sys.stdout/sys.stderr streams are in text
44         # mode.  This means they expect unicode, and will encode the
45         # unicode automatically before actually writing to stdout/stderr.
46         # In python2, that's not the case.  In order to provide a consistent
47         # interface, we can create a wrapper around sys.stdout that will take
48         # unicode, and automatically encode it to the preferred encoding.
49         # That way consumers can just call get_stdout_text_writer() and write
50         # unicode to the returned stream.  Note that get_stdout_text_writer
51         # just returns sys.stdout in the PY3 section above because python3
52         # handles this.
53         return codecs.getwriter(locale.getpreferredencoding())(sys.stdout)
54 
55     def compat_open(filename, mode='r', encoding=None):
56         # See docstring for compat_open in the PY3 section above.
57         if 'b' not in mode:
58             encoding = locale.getpreferredencoding()
59         return io.open(filename, mode, encoding=encoding)
60
```

Path: `awscli/customizations/globalargs.py`
Content:
```
1 # Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License"). You
4 # may not use this file except in compliance with the License. A copy of
5 # the License is located at
6 #
7 #     http://aws.amazon.com/apache2.0/
8 #
9 # or in the "license" file accompanying this file. This file is
10 # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11 # ANY KIND, either express or implied. See the License for the specific
12 # language governing permissions and limitations under the License.
13 import sys
14 import os
15 
16 import jmespath
17 
18 
19 def register_parse_global_args(cli):
20     cli.register('top-level-args-parsed', resolve_types)
21     cli.register('top-level-args-parsed', no_sign_request)
22 
23 
24 def resolve_types(parsed_args, **kwargs):
25     # This emulates the "type" arg from argparse, but does so in a way
26     # that plugins can also hook into this process.
27     _resolve_arg(parsed_args, 'query')
28     _resolve_arg(parsed_args, 'verify_ssl')
29 
30 
31 def _resolve_arg(parsed_args, name):
32     value = getattr(parsed_args, name, None)
33     if value is not None:
34         new_value = getattr(sys.modules[__name__], '_resolve_%s' % name)(value)
35         setattr(parsed_args, name, new_value)
36 
37 
38 def _resolve_query(value):
39     try:
40         return jmespath.compile(value)
41     except Exception as e:
42         raise ValueError("Bad value for --query %s: %s" % (value, str(e)))
43 
44 
45 def _resolve_verify_ssl(value):
46     verify = None
47     if not value:
48         verify = False
49     else:
50         verify = os.environ.get('AWS_CA_BUNDLE')
51     return verify
52 
53 
54 def no_sign_request(parsed_args, session, **kwargs):
55     if not parsed_args.sign_request:
56         # In order to make signing disabled for all requests
57         # we need to set the signature_version to None for
58         # any service created.  This ensures that get_endpoint()
59         # will not look for auth.
60         session.register('service-created', disable_signing)
61 
62 
63 def disable_signing(service, **kwargs):
64     service.signature_version = None
65
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/awscli/compat.py b/awscli/compat.py
--- a/awscli/compat.py
+++ b/awscli/compat.py
@@ -15,6 +15,7 @@
 
 if six.PY3:
     import locale
+    import urllib.parse as urlparse
 
     def get_stdout_text_writer():
         return sys.stdout
@@ -38,6 +39,7 @@
     import codecs
     import locale
     import io
+    import urlparse
 
     def get_stdout_text_writer():
         # In python3, all the sys.stdout/sys.stderr streams are in text
diff --git a/awscli/customizations/globalargs.py b/awscli/customizations/globalargs.py
--- a/awscli/customizations/globalargs.py
+++ b/awscli/customizations/globalargs.py
@@ -15,6 +15,8 @@
 
 import jmespath
 
+from awscli.compat import urlparse
+
 
 def register_parse_global_args(cli):
     cli.register('top-level-args-parsed', resolve_types)
@@ -26,6 +28,7 @@
     # that plugins can also hook into this process.
     _resolve_arg(parsed_args, 'query')
     _resolve_arg(parsed_args, 'verify_ssl')
+    _resolve_arg(parsed_args, 'endpoint_url')
 
 
 def _resolve_arg(parsed_args, name):
@@ -51,6 +54,17 @@
     return verify
 
 
+def _resolve_endpoint_url(value):
+    parsed = urlparse.urlparse(value)
+    # Our http library requires you specify an endpoint url
+    # that contains a scheme, so we'll verify that up front.
+    if not parsed.scheme:
+        raise ValueError('Bad value for --endpoint-url "%s": scheme is '
+                         'missing.  Must be of the form '
+                         'http://<hostname>/ or https://<hostname>/' % value)
+    return value
+
+
 def no_sign_request(parsed_args, session, **kwargs):
     if not parsed_args.sign_request:
         # In order to make signing disabled for all requests

{"golden_diff": "diff --git a/awscli/compat.py b/awscli/compat.py\n--- a/awscli/compat.py\n+++ b/awscli/compat.py\n@@ -15,6 +15,7 @@\n \n if six.PY3:\n     import locale\n+    import urllib.parse as urlparse\n \n     def get_stdout_text_writer():\n         return sys.stdout\n@@ -38,6 +39,7 @@\n     import codecs\n     import locale\n     import io\n+    import urlparse\n \n     def get_stdout_text_writer():\n         # In python3, all the sys.stdout/sys.stderr streams are in text\ndiff --git a/awscli/customizations/globalargs.py b/awscli/customizations/globalargs.py\n--- a/awscli/customizations/globalargs.py\n+++ b/awscli/customizations/globalargs.py\n@@ -15,6 +15,8 @@\n \n import jmespath\n \n+from awscli.compat import urlparse\n+\n \n def register_parse_global_args(cli):\n     cli.register('top-level-args-parsed', resolve_types)\n@@ -26,6 +28,7 @@\n     # that plugins can also hook into this process.\n     _resolve_arg(parsed_args, 'query')\n     _resolve_arg(parsed_args, 'verify_ssl')\n+    _resolve_arg(parsed_args, 'endpoint_url')\n \n \n def _resolve_arg(parsed_args, name):\n@@ -51,6 +54,17 @@\n     return verify\n \n \n+def _resolve_endpoint_url(value):\n+    parsed = urlparse.urlparse(value)\n+    # Our http library requires you specify an endpoint url\n+    # that contains a scheme, so we'll verify that up front.\n+    if not parsed.scheme:\n+        raise ValueError('Bad value for --endpoint-url \"%s\": scheme is '\n+                         'missing.  Must be of the form '\n+                         'http://<hostname>/ or https://<hostname>/' % value)\n+    return value\n+\n+\n def no_sign_request(parsed_args, session, **kwargs):\n     if not parsed_args.sign_request:\n         # In order to make signing disabled for all requests\n", "issue": "Provide better error message for invalid endpoint urls\nThe error message could provide more context about what exactly went wrong with the request.  For example:\n\n```\n$ aws s3api list-buckets --endpoint-url example.com\n\nInvalid URL u'/': No schema supplied\n```\n\nA better error message would be something like:\n\n```\n$ aws s3api list-buckets --endpoint-url example.com\n\nBad value for --endpoint-url \"example.com\": scheme is missing.  Must be of the form http://<hostname>/ or https://<hostname>/\n```\n\n", "before_files": [{"content": "# Copyright 2012-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n\n# Licensed under the Apache License, Version 2.0 (the \"License\"). You\n# may not use this file except in compliance with the License. A copy of\n# the License is located at\n\n#     http://aws.amazon.com/apache2.0/\n\n# or in the \"license\" file accompanying this file. This file is\n# distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF\n# ANY KIND, either express or implied. See the License for the specific\n# language governing permissions and limitations under the License.\nimport sys\nimport six\n\nif six.PY3:\n    import locale\n\n    def get_stdout_text_writer():\n        return sys.stdout\n\n    def compat_open(filename, mode='r', encoding=None):\n        \"\"\"Back-port open() that accepts an encoding argument.\n\n        In python3 this uses the built in open() and in python2 this\n        uses the io.open() function.\n\n        If the file is not being opened in binary mode, then we'll\n        use locale.getpreferredencoding() to find the preferred\n        encoding.\n\n        \"\"\"\n        if 'b' not in mode:\n            encoding = locale.getpreferredencoding()\n        return open(filename, mode, encoding=encoding)\n\nelse:\n    import codecs\n    import locale\n    import io\n\n    def get_stdout_text_writer():\n        # In python3, all the sys.stdout/sys.stderr streams are in text\n        # mode.  This means they expect unicode, and will encode the\n        # unicode automatically before actually writing to stdout/stderr.\n        # In python2, that's not the case.  In order to provide a consistent\n        # interface, we can create a wrapper around sys.stdout that will take\n        # unicode, and automatically encode it to the preferred encoding.\n        # That way consumers can just call get_stdout_text_writer() and write\n        # unicode to the returned stream.  Note that get_stdout_text_writer\n        # just returns sys.stdout in the PY3 section above because python3\n        # handles this.\n        return codecs.getwriter(locale.getpreferredencoding())(sys.stdout)\n\n    def compat_open(filename, mode='r', encoding=None):\n        # See docstring for compat_open in the PY3 section above.\n        if 'b' not in mode:\n            encoding = locale.getpreferredencoding()\n        return io.open(filename, mode, encoding=encoding)\n", "path": "awscli/compat.py"}, {"content": "# Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\"). You\n# may not use this file except in compliance with the License. A copy of\n# the License is located at\n#\n#     http://aws.amazon.com/apache2.0/\n#\n# or in the \"license\" file accompanying this file. This file is\n# distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF\n# ANY KIND, either express or implied. See the License for the specific\n# language governing permissions and limitations under the License.\nimport sys\nimport os\n\nimport jmespath\n\n\ndef register_parse_global_args(cli):\n    cli.register('top-level-args-parsed', resolve_types)\n    cli.register('top-level-args-parsed', no_sign_request)\n\n\ndef resolve_types(parsed_args, **kwargs):\n    # This emulates the \"type\" arg from argparse, but does so in a way\n    # that plugins can also hook into this process.\n    _resolve_arg(parsed_args, 'query')\n    _resolve_arg(parsed_args, 'verify_ssl')\n\n\ndef _resolve_arg(parsed_args, name):\n    value = getattr(parsed_args, name, None)\n    if value is not None:\n        new_value = getattr(sys.modules[__name__], '_resolve_%s' % name)(value)\n        setattr(parsed_args, name, new_value)\n\n\ndef _resolve_query(value):\n    try:\n        return jmespath.compile(value)\n    except Exception as e:\n        raise ValueError(\"Bad value for --query %s: %s\" % (value, str(e)))\n\n\ndef _resolve_verify_ssl(value):\n    verify = None\n    if not value:\n        verify = False\n    else:\n        verify = os.environ.get('AWS_CA_BUNDLE')\n    return verify\n\n\ndef no_sign_request(parsed_args, session, **kwargs):\n    if not parsed_args.sign_request:\n        # In order to make signing disabled for all requests\n        # we need to set the signature_version to None for\n        # any service created.  This ensures that get_endpoint()\n        # will not look for auth.\n        session.register('service-created', disable_signing)\n\n\ndef disable_signing(service, **kwargs):\n    service.signature_version = None\n", "path": "awscli/customizations/globalargs.py"}], "after_files": [{"content": "# Copyright 2012-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n\n# Licensed under the Apache License, Version 2.0 (the \"License\"). You\n# may not use this file except in compliance with the License. A copy of\n# the License is located at\n\n#     http://aws.amazon.com/apache2.0/\n\n# or in the \"license\" file accompanying this file. This file is\n# distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF\n# ANY KIND, either express or implied. See the License for the specific\n# language governing permissions and limitations under the License.\nimport sys\nimport six\n\nif six.PY3:\n    import locale\n    import urllib.parse as urlparse\n\n    def get_stdout_text_writer():\n        return sys.stdout\n\n    def compat_open(filename, mode='r', encoding=None):\n        \"\"\"Back-port open() that accepts an encoding argument.\n\n        In python3 this uses the built in open() and in python2 this\n        uses the io.open() function.\n\n        If the file is not being opened in binary mode, then we'll\n        use locale.getpreferredencoding() to find the preferred\n        encoding.\n\n        \"\"\"\n        if 'b' not in mode:\n            encoding = locale.getpreferredencoding()\n        return open(filename, mode, encoding=encoding)\n\nelse:\n    import codecs\n    import locale\n    import io\n    import urlparse\n\n    def get_stdout_text_writer():\n        # In python3, all the sys.stdout/sys.stderr streams are in text\n        # mode.  This means they expect unicode, and will encode the\n        # unicode automatically before actually writing to stdout/stderr.\n        # In python2, that's not the case.  In order to provide a consistent\n        # interface, we can create a wrapper around sys.stdout that will take\n        # unicode, and automatically encode it to the preferred encoding.\n        # That way consumers can just call get_stdout_text_writer() and write\n        # unicode to the returned stream.  Note that get_stdout_text_writer\n        # just returns sys.stdout in the PY3 section above because python3\n        # handles this.\n        return codecs.getwriter(locale.getpreferredencoding())(sys.stdout)\n\n    def compat_open(filename, mode='r', encoding=None):\n        # See docstring for compat_open in the PY3 section above.\n        if 'b' not in mode:\n            encoding = locale.getpreferredencoding()\n        return io.open(filename, mode, encoding=encoding)\n", "path": "awscli/compat.py"}, {"content": "# Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\"). You\n# may not use this file except in compliance with the License. A copy of\n# the License is located at\n#\n#     http://aws.amazon.com/apache2.0/\n#\n# or in the \"license\" file accompanying this file. This file is\n# distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF\n# ANY KIND, either express or implied. See the License for the specific\n# language governing permissions and limitations under the License.\nimport sys\nimport os\n\nimport jmespath\n\nfrom awscli.compat import urlparse\n\n\ndef register_parse_global_args(cli):\n    cli.register('top-level-args-parsed', resolve_types)\n    cli.register('top-level-args-parsed', no_sign_request)\n\n\ndef resolve_types(parsed_args, **kwargs):\n    # This emulates the \"type\" arg from argparse, but does so in a way\n    # that plugins can also hook into this process.\n    _resolve_arg(parsed_args, 'query')\n    _resolve_arg(parsed_args, 'verify_ssl')\n    _resolve_arg(parsed_args, 'endpoint_url')\n\n\ndef _resolve_arg(parsed_args, name):\n    value = getattr(parsed_args, name, None)\n    if value is not None:\n        new_value = getattr(sys.modules[__name__], '_resolve_%s' % name)(value)\n        setattr(parsed_args, name, new_value)\n\n\ndef _resolve_query(value):\n    try:\n        return jmespath.compile(value)\n    except Exception as e:\n        raise ValueError(\"Bad value for --query %s: %s\" % (value, str(e)))\n\n\ndef _resolve_verify_ssl(value):\n    verify = None\n    if not value:\n        verify = False\n    else:\n        verify = os.environ.get('AWS_CA_BUNDLE')\n    return verify\n\n\ndef _resolve_endpoint_url(value):\n    parsed = urlparse.urlparse(value)\n    # Our http library requires you specify an endpoint url\n    # that contains a scheme, so we'll verify that up front.\n    if not parsed.scheme:\n        raise ValueError('Bad value for --endpoint-url \"%s\": scheme is '\n                         'missing.  Must be of the form '\n                         'http://<hostname>/ or https://<hostname>/' % value)\n    return value\n\n\ndef no_sign_request(parsed_args, session, **kwargs):\n    if not parsed_args.sign_request:\n        # In order to make signing disabled for all requests\n        # we need to set the signature_version to None for\n        # any service created.  This ensures that get_endpoint()\n        # will not look for auth.\n        session.register('service-created', disable_signing)\n\n\ndef disable_signing(service, **kwargs):\n    service.signature_version = None\n", "path": "awscli/customizations/globalargs.py"}]}