Tencent/WeKnora · error

list team repos: %w

Error message

list team repos: %w

What it means

This error wraps a failure from cli.ListGroupRepos while ListResources is listing a Yuque team (Group-type token) knowledge base repos. The connector detected that the token belongs to a Group user, so it lists the group's repos directly; when that upstream API call fails, the underlying error is preserved via %w and prefixed with this message.

Source

Thrown at internal/datasource/connector/yuque/connector.go:82

		return nil, err
	}
	cli := newClient(cfg)

	me, err := cli.GetCurrentUser(ctx)
	if err != nil {
		return nil, fmt.Errorf("get current user: %w", err)
	}

	repos := make(map[int64]v2Repo)

	// Team token: /api/v2/user returns type="Group" — the token represents a team,
	// not a personal user. In this case, directly list the team's own repos instead
	// of going through the personal-repos + user-groups flow.
	if me.Type == "Group" {
		logger.Infof(ctx, "[Yuque] detected team token (type=Group, login=%s), listing team repos directly", me.Login)
		teamRepos, err := cli.ListGroupRepos(ctx, me.Login)
		if err != nil {
			return nil, fmt.Errorf("list team repos: %w", err)
		}
		for _, r := range teamRepos {
			repos[r.ID] = r
		}
	} else {
		// Personal token flow: list user's own repos + repos from joined groups.
		personal, err := cli.ListUserRepos(ctx, me.Login)
		if err != nil {
			return nil, fmt.Errorf("list personal repos: %w", err)
		}
		for _, r := range personal {
			if _, ok := repos[r.ID]; !ok {
				repos[r.ID] = r
			}
		}

		groups, err := cli.ListUserGroups(ctx, me.ID)
		if err != nil {

View on GitHub (pinned to 988cbb0330)

Solutions

  1. Verify the token is valid and belongs to the intended Yuque organization (curl https://api.yuque.com/api/v2/user with the token)
  2. Re-generate the organization token with repo read scope and update the datasource config
  3. Check the wrapped error for 401/403/404: 403 usually means missing scope, 404 means the group login no longer exists
  4. Confirm network egress to api.yuque.com from the connector host

Example fix

// before
repos, err := cli.ListGroupRepos(ctx, me.Login)
if err != nil {
    return nil, fmt.Errorf("list team repos: %w", err)
}
// after
if me.Login == "" {
    return nil, fmt.Errorf("team token returned empty login; check token validity")
}
repos, err := cli.ListGroupRepos(ctx, me.Login)
if err != nil {
    return nil, fmt.Errorf("list team repos (login=%s): %w", me.Login, err)
}
Defensive patterns

Strategy: try-catch

Validate before calling

// Before invoking the datasource, verify the token and team access:
resp, err := http.NewRequestWithContext(ctx, "GET", "https://api.yuque.com/api/v2/user", nil)
// req.Header.Set("X-Auth-Token", token)
// if err or non-200 -> fix token before configuring the connector

Type guard

// Go: check the wrapped cause to branch on auth vs network failures
var apiErr *yuque.APIError
if errors.As(err, &apiErr) && apiErr.StatusCode == 401 {
    // token invalid: prompt re-authentication
}

Try / catch

items, err := ds.ListResources(ctx, cfg)
if err != nil {
    if errors.Is(err, context.DeadlineExceeded) {
        return retryWithBackoff(ctx)
    }
    return fmt.Errorf("yuque team repo listing failed: %w", err)
}

Prevention

When it happens

Trigger: A team token whose /me response has Type == "Group" is used and the ListGroupRepos API call for that login returns an error (auth failure, network error, API rate limit, or the group login being invalid/deleted).

Common situations: Organization tokens issued for a deleted or renamed Yuque org; expired or revoked team token; network restrictions blocking api.yuque.com; the token lacking read scope on the group's repos.

Related errors


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