AlistGo/alist · error

get upload server failed: %w

Error message

get upload server failed: %w

What it means

During upload (Put), the Darkibox driver first calls /upload/server to discover which upload endpoint to use. This error means that discovery call failed; the %w chain holds the actual callAPI failure (HTTP, API status, or decode). No bytes were sent.

Source

Thrown at drivers/darkibox/driver.go:237

		}, nil)
	}

	fileCode := fileCodeFromObjID(obj.GetID())
	return d.callAPI(ctx, "/file/delete", map[string]string{
		"file_code": fileCode,
	}, nil)
}

func (d *Darkibox) Put(ctx context.Context, dstDir model.Obj, file model.FileStreamer, up driver.UpdateProgress) (model.Obj, error) {
	folderID := d.RootFolderID
	if dstDir.GetID() != "" {
		folderID = folderIDFromObjID(dstDir.GetID())
	}

	// Step 1: Get the upload server URL
	var server uploadServerResult
	if err := d.callAPI(ctx, "/upload/server", nil, &server); err != nil {
		return nil, fmt.Errorf("get upload server failed: %w", err)
	}
	if server.URL == "" {
		return nil, fmt.Errorf("no upload server URL returned")
	}

	// Step 2: Upload the file to the upload server
	reader := driver.NewLimitedUploadStream(ctx, &driver.ReaderUpdatingProgress{
		Reader:         file,
		UpdateProgress: up,
	})

	res, err := base.RestyClient.R().
		SetContext(ctx).
		SetMultipartField("file", file.GetName(), "", reader).
		SetMultipartFormData(map[string]string{
			"key":    d.APIKey,
			"fld_id": fldIDStr(folderID),
		}).

View on GitHub (pinned to 843d9dc814)

Solutions

  1. Read the wrapped error — if it says 'darkibox api error: status=... msg=...', the provider rejected the key/quota; renew the key in the driver config
  2. Retry after confirming the account can upload via the Darkibox web UI
  3. If it is a decode failure, the provider changed the response schema — update uploadServerResult to match the new JSON

Example fix

// before
if err := d.callAPI(ctx, "/upload/server", nil, &server); err != nil {
	return nil, fmt.Errorf("get upload server failed: %w", err)
}
// after — nothing to change at the call site; guard the shape after success too (see 664). Keep this wrap but log server URL on later failure for correlation.
Defensive patterns

Strategy: try-catch

Validate before calling

if d.APIKey == "" {
	return errors.New("darkibox API key not configured")
}

Try / catch

if err != nil && strings.Contains(err.Error(), "get upload server failed") {
	if isAuthError(err) {
		return promptReconfigureKey()
	}
	return backoffRetry(upload, 3)
}

Prevention

When it happens

Trigger: GET /upload/server returns non-200 HTTP status, provider status != 200 (bad key, maintenance), or the response body's Result field fails to unmarshal into uploadServerResult.

Common situations: API key invalid or out of upload quota; provider rotating/disabling upload servers; network proxy stripping query params (the key travels as a query param via callAPI); apiBase domain changed.

Related errors


AI-assisted analysis of AlistGo/alist@843d9dc814 (2026-08-15). Data as JSON: /api/errors/7ab5c642d20e3387. Report an issue: GitHub.