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 26 forks source link

validate source-id when uploading #165

Closed Pshrawani closed 2 years ago

Pshrawani commented 2 years ago

Summary

This PR resolves Connection reset by peer error by first validating the source id, if it's not in a correct format a friendly error message will be thrown.

Tests

Tested by passing incorrect source-id when using upload-source command

tilesets upload-source username mapbox://tileset-source/username/populated-places-source ./populated_places.geojson.ld
Error: Invalid value for 'ID': Tileset Source ID is invalid. Must be no more than 32 characters and only include "-", "_", and alphanumeric characters.

Successfully uploaded a new source id, created and published a new tileset

tilesets-cli % tilesets upload-source username new-source-id ./populated_places.geojson.ld
{"id": "mapbox://tileset-source/username/new-source-id", "files": 1, "source_size": 17789697, "file_size": 17789697}
tilesets create username.new-source-id --recipe ./recipe.json --name "big cities"
{"message": "Successfully created empty tilesetusername.new-source-id. Publish your tileset to begin processing your data into vector tiles."}
tilesets publish username.new-source-id
{"message": "Processing username.new-source-id", "jobId": "XXX"}