Skip to content

fix(datasource): support Yuque team token in connector#1477

Open
Once-the-sea-was-difficult-for-water wants to merge 1 commit into
Tencent:mainfrom
Once-the-sea-was-difficult-for-water:fix/yuque-team-token-support
Open

fix(datasource): support Yuque team token in connector#1477
Once-the-sea-was-difficult-for-water wants to merge 1 commit into
Tencent:mainfrom
Once-the-sea-was-difficult-for-water:fix/yuque-team-token-support

Conversation

@Once-the-sea-was-difficult-for-water
Copy link
Copy Markdown

Description

When using a Yuque team token, the connector calls GET /api/v2/users/{id}/groups which returns 404 because a team entity is not a user. This causes ListResources to fail entirely, blocking data source setup.

Additionally, personal tokens without any team memberships also trigger 404 (Yuque returns 404 instead of an empty list), causing the same fatal error.

This PR:

  • Adds Type field to v2User struct to detect token type ("User" vs "Group")
  • Routes team tokens directly to ListGroupRepos, skipping ListUserGroups
  • Gracefully handles ListUserGroups 404 for personal tokens without teams (warn + fallback to empty)
  • Adds 300ms delay between GetDocDetail calls to prevent Yuque API rate limiting (429)

Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • 💥 Breaking change
  • 📚 Documentation update
  • 🎨 Refactor
  • ⚡ Performance improvement
  • 🧪 Test
  • 🔧 Configuration / Build / CI

Related Issue

N/A

Testing

  1. Configured Yuque data source with a team token
  2. Verified ListResources returns team knowledge bases successfully (previously returned 404)
  3. Triggered full sync of 247 docs — all completed without rate limit errors
  4. Verified personal token (no teams) also works with graceful 404 handling
  5. Incremental sync correctly detects no changes on second run

Checklist

  • Self-reviewed the code
  • make fmt && make lint && make test pass locally
  • Added/updated tests covering the change
  • Updated related documentation (README, docs/, Swagger annotations, etc.)
  • Breaking changes are clearly called out in the description above

Screenshots / Recordings

N/A (backend-only change, no UI impact)

- Add Type field to v2User struct to distinguish personal/team tokens
- Route team tokens directly to ListGroupRepos (skip ListUserGroups)
- Gracefully handle ListUserGroups 404 for personal tokens without teams
- Add rate-limiting delay between GetDocDetail calls to avoid API throttling
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant