gildas-lormeau/SingleFile · error · Error

response.error

Error message

response.error

What it means

getJSON parses a Dropbox API response body and throws Error(response.error) whenever the JSON contains an 'error' field. The thrown message is the raw error value from Dropbox, so its shape depends entirely on what Dropbox returned (often an object or reason string).

Source

Thrown at src/lib/dropbox/dropbox.js:336

				}
			})
		}
	});
	if (httpFinishResponse.status == 200) {
		return getJSON(httpFinishResponse);
	} else if (httpFinishResponse.status == 409 && mediaUploader.filenameConflictAction == CONFLICT_ACTION_PROMPT) {
		mediaUploader.offset = 0;
		return mediaUploader.upload();
	} else {
		throw new Error("unknown_error (" + httpFinishResponse.status + ")");
	}
}

async function getJSON(httpResponse) {
	httpResponse = getResponse(httpResponse);
	const response = await httpResponse.json();
	if (response.error) {
		throw new Error(response.error);
	} else {
		return response;
	}
}

function getResponse(httpResponse) {
	if (httpResponse.status == 200) {
		return httpResponse;
	} else if (httpResponse.status == 401) {
		throw new Error("invalid_token");
	} else {
		throw new Error("unknown_error (" + httpResponse.status + ")");
	}
}

function stringify(value) {
	return JSON.stringify(value).replace(ENCODED_CHARS,
		function (c) {

View on GitHub (pinned to 517fb7c5cf)

Solutions

  1. Inspect the thrown error value — it is Dropbox's own error payload — and fix the root cause it describes.
  2. Re-authenticate if the error indicates invalid/expired token.
  3. Validate request parameters (paths, cursors, options) against the Dropbox API docs.
  4. Add retry with backoff for rate-limit (too_many_requests / retry-after) errors.

Example fix

// before
const data = await dropbox.getFile(...); // throws raw Dropbox error
// after
try {
  const data = await dropbox.getFile(...);
} catch (e) {
  const reason = typeof e.message === 'string' ? e.message : JSON.stringify(e.message);
  if (reason.includes('expired_access_token')) await reauthorize();
  else throw e;
}
Defensive patterns

Strategy: try-catch

Try / catch

try {
  const data = await dropboxCall(...);
} catch (e) {
  // e.message is Dropbox's raw error payload
  const reason = typeof e.message === 'string' ? e.message : JSON.stringify(e.message);
  if (reason.includes('expired_access_token') || reason.includes('invalid_access_token')) {
    await reauthorize();
  } else if (reason.includes('too_many_requests')) {
    await sleep(backoff); // retry
  } else throw e;
}

Prevention

When it happens

Trigger: Any Dropbox endpoint call (via getJSON) that returns 200 but with an error payload — e.g. rate-limit details, invalid cursor, malformed arguments reported inside a 200/other response.

Common situations: Expired or insufficient-scope tokens producing Dropbox error payloads; malformed paths or upload parameters; paginated list calls with invalid/stale cursors.

Related errors


AI-assisted analysis of gildas-lormeau/SingleFile@517fb7c5cf (2026-09-01). Data as JSON: /api/errors/6595e65bf11a6558. Report an issue: GitHub.