mapbox / tilesets-cli

CLI for interacting with the Mapbox Tilesets API and Mapbox Tiling Service
https://docs.mapbox.com/mapbox-tiling-service
BSD 2-Clause "Simplified" License
125 stars 27 forks source link

Confusing error message when uploading long source name #133

Closed e-n-f closed 2 years ago

e-n-f commented 3 years ago
➤ tilesets upload-source --no-validation enf abcdefghijklmnopqrstuvwxyz1234567890 ne_10m_admin_0_countries.ldjson

Traceback (most recent call last):
  File "/Users/enf/python-venv/lib/python3.8/site-packages/urllib3/connectionpool.py", line 670, in urlopen
    httplib_response = self._make_request(
  File "/Users/enf/python-venv/lib/python3.8/site-packages/urllib3/connectionpool.py", line 392, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/local/Cellar/python@3.8/3.8.6/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 1255, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/local/Cellar/python@3.8/3.8.6/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 1301, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/local/Cellar/python@3.8/3.8.6/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 1250, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/local/Cellar/python@3.8/3.8.6/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 1049, in _send_output
    self.send(chunk)
  File "/usr/local/Cellar/python@3.8/3.8.6/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 971, in send
    self.sock.sendall(data)
  File "/usr/local/Cellar/python@3.8/3.8.6/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ssl.py", line 1204, in sendall
    v = self.send(byte_view[count:])
  File "/usr/local/Cellar/python@3.8/3.8.6/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ssl.py", line 1173, in send
    return self._sslobj.write(data)
BrokenPipeError: [Errno 32] Broken pipe

During handling of the above exception, another exception occurred:
…

The error appears to be that enf.abcdefghijklmnopqrstuvwxyz1234567890 is too long a name for a source, but I get a bunch of unrelated and confusing stack traces instead of being told that.

Gerdie commented 2 years ago

This now raises the following error:

mapbox_tilesets.errors.TilesetsError: {"message":"Tileset Source ID abcdefghijklmnopqrstuvwxyz1234567890 is invalid. Must be no more than 32 characters and only include \"-\", \"_\", and alphanumeric characters."}

Although the broken pipe exception is still relevant in that the CLI will not validate the size of the source name before it attempts the large upload, and if a large upload hangs, we might see a broken pipe error instead of the source name error.