juicedata/juicefs · error

invalid endpoint: %v, error: %v

Error message

invalid endpoint: %v, error: %v

What it means

url.ParseRequestURI rejected the Volcengine TOS endpoint after HTTPS scheme prefixing. Validation guard: the endpoint string is not a parseable URI, so the TOS SDK client cannot be constructed for it.

Source

Thrown at pkg/object/tos.go:316

	return err
}
func (t *tosClient) Restore(ctx context.Context, key string, days int32) error {
	_, err := t.client.RestoreObject(ctx, &tos.RestoreObjectInput{
		Bucket:               t.bucket,
		Key:                  key,
		Days:                 int(days),
		RestoreJobParameters: &tos.RestoreJobParameters{Tier: enum.TierStandard},
	})
	return err
}

func newTOS(endpoint, accessKey, secretKey, token string) (ObjectStorage, error) {
	if !strings.Contains(endpoint, "://") {
		endpoint = fmt.Sprintf("https://%s", endpoint)
	}
	uri, err := url.ParseRequestURI(endpoint)
	if err != nil {
		return nil, fmt.Errorf("invalid endpoint: %v, error: %v", endpoint, err)
	}
	disableChecksum := strings.EqualFold(uri.Query().Get("disable-checksum"), "true")
	if disableChecksum {
		logger.Infof("default CRC checksum is disabled")
	}
	hostParts := strings.SplitN(uri.Host, ".", 3)
	credentials := tos.NewStaticCredentials(accessKey, secretKey)
	credentials.WithSecurityToken(token)
	cli, err := tos.NewClientV2(
		hostParts[1]+"."+hostParts[2],
		tos.WithRegion(strings.TrimPrefix(hostParts[1], "tos-")),
		tos.WithCredentials(credentials),
		tos.WithUserAgentProductName(UserAgent),
		tos.WithEnableVerifySSL(httpClient.Transport.(*http.Transport).TLSClientConfig.InsecureSkipVerify),
		tos.WithEnableCRC(!disableChecksum))
	if err != nil {
		return nil, err
	}

View on GitHub (pinned to c9a67b23e8)

Solutions

  1. Print and inspect the endpoint string; remove whitespace/control characters
  2. Use a plain host like tos-cn-beijing.volces.com, or with an explicit https:// scheme
  3. Ensure the config value is actually substituted (no leftover {{var}} or $VAR)
  4. Percent-encode any characters that are not valid in a URL

Example fix

// before
--storage-url "tos://tos cn-beijing.volces.com"
// after
--storage-url "tos://tos-cn-beijing.volces.com"
Defensive patterns

Strategy: validation

Validate before calling

func validTOSEndpoint(ep string) error {
	if !strings.Contains(ep, "://") { ep = "https://" + ep }
	_, err := url.ParseRequestURI(ep)
	return err
}

Try / catch

_, err := object.CreateStorage(ctx, "tos", url, ak, sk)
if err != nil && strings.HasPrefix(err.Error(), "invalid endpoint") {
	// fix the endpoint string and retry
}

Prevention

When it happens

Trigger: Creating a TOS object store with an endpoint that is empty, contains illegal characters, or is otherwise unparseable as a URL even after adding the https:// scheme (e.g. "tos://bad url", "not%valid").

Common situations: Typo or stray whitespace in the endpoint config value; pasting a full TOS ARN instead of a host; config template variable left unexpanded; URL-encoded characters that break ParseRequestURI.

Understand the failure class

Background: "Invalid URL" / "URL cannot be empty": fix the malformed or missing URL behind request-construction failures — this error's family across 50 libraries.

Related errors


AI-assisted analysis of juicedata/juicefs@c9a67b23e8 (2026-09-06). Data as JSON: /api/errors/febf0c9e11a3b9c8. Report an issue: GitHub.