Skip to content

Commit

Permalink
STRF-4889: Fix error message for upload limit
Browse files Browse the repository at this point in the history
* Status code 409 is overloaded for two conditions: (1) Private theme
  count limit (2) Private theme concurrent upload limit.
* Use the error message to disambiguate and present the correct error.
  This is fragile, but all we have at the moment.
  • Loading branch information
mattolson committed May 17, 2018
1 parent 8303b26 commit 95ba66b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions lib/theme-api-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,20 @@ function postTheme(options, callback) {
}

if (response.statusCode === 409) {
return callback(null, { themeLimitReached: true });
// This status code is overloaded, so we need to check the message to determine
// if we want to trigger the theme deletion flow.
const uploadLimitPattern = /You have reached your upload limit/;
if (payload && payload.title && uploadLimitPattern.exec(payload.title)) {
return callback(null, { themeLimitReached: true });
}

const message = 'You already have a theme upload in progress. You will need to wait for it to finish processing before uploading a new one.';
return callback(new Error(payload && payload.title || message));
}

if (response.statusCode === 413) {
return callback(new Error(payload && payload.title || 'Theme Bundle Size Limit Reached'));
const message = 'Your theme bundle is too large. Please reduce the size of your assets to bring the zip file size under 50MB.';
return callback(new Error(payload && payload.title || message));
}

if (response.statusCode !== 201) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bigcommerce/stencil-cli",
"version": "1.14.2",
"version": "1.14.3",
"description": "CLI tool to run BigCommerce Stores locally for theme development.",
"main": "index.js",
"engines": {
Expand Down

0 comments on commit 95ba66b

Please sign in to comment.