Tencent/WeKnora · error

failed to initialize OSS temp client: %w

Error message

failed to initialize OSS temp client: %w

What it means

Constructing the secondary OSS client for the temp bucket failed after the main bucket was ensured: newOSSClient for the temp region/credentials (or SSRF endpoint validation on it) errored, so temp-bucket support cannot be initialized.

Source

Thrown at internal/application/service/file/oss.go:98

// NewOssFileServiceWithTempBucket creates an Aliyun OSS file service with optional temp bucket.
func NewOssFileServiceWithTempBucket(endpoint, region, accessKey, secretKey, bucketName, pathPrefix, tempBucketName, tempRegion string) (interfaces.FileService, error) {
	client, err := newOSSClient(endpoint, region, accessKey, secretKey)
	if err != nil {
		return nil, err
	}

	if err := ossEnsureBucket(client, bucketName); err != nil {
		return nil, err
	}

	var tempClient *oss.Client
	if tempBucketName != "" {
		if tempRegion == "" {
			tempRegion = region
		}
		tempClient, err = newOSSClient(endpoint, tempRegion, accessKey, secretKey)
		if err != nil {
			return nil, fmt.Errorf("failed to initialize OSS temp client: %w", err)
		}
		if err := ossEnsureBucket(tempClient, tempBucketName); err != nil {
			return nil, err
		}
	}

	// Normalize pathPrefix: ensure it ends with '/' if not empty
	if pathPrefix != "" && !strings.HasSuffix(pathPrefix, "/") {
		pathPrefix += "/"
	}

	return &ossFileService{
		client:         client,
		tempClient:     tempClient,
		pathPrefix:     pathPrefix,
		bucketName:     bucketName,
		tempBucketName: tempBucketName,
	}, nil

View on GitHub (pinned to 988cbb0330)

Solutions

  1. Verify temp bucket endpoint, region, and credentials
  2. Check SSRF allowlisting for the temp endpoint
  3. Disable temp bucket config if the feature is unused
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at internal/application/service/file/oss.go:98 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02). Data as JSON: /api/errors/69ec89b838716f9d. Report an issue: GitHub.