fix(datasource): lazy-load Feishu wiki resources to avoid listing timeout (#1672)

Listing resources for a Feishu data source eagerly walked the entire wiki
tree (one API call per node across every space), which exceeded the request
timeout for large knowledge bases. ListResources now takes a parentID and
returns a single level at a time: empty lists the wiki spaces, a space/node
ID lists only its direct children. The frontend fetches children on demand
when a node is expanded. Notion (full tree in one call) and Yuque (flat)
keep their existing behavior by ignoring non-empty parentID.

Refs: https://github.com/Tencent/WeKnora/issues/1672
This commit is contained in:
wizardchen
2026-06-22 17:41:18 +08:00
committed by lyingbug
parent 74c845a1f4
commit d8f13ada4a
12 changed files with 204 additions and 62 deletions
+4 -2
View File
@@ -330,10 +330,11 @@ func (h *DataSourceHandler) ValidateCredentials(c *gin.Context) {
}
// @Summary List available resources in data source
// @Description List resources available for sync in the external system
// @Description List resources available for sync in the external system. Pass parent_id to lazily load the direct children of a resource (used for large hierarchical sources such as Feishu wiki).
// @Tags DataSource
// @Produce json
// @Param id path string true "Data source ID"
// @Param parent_id query string false "Parent resource ExternalID; empty lists the top level"
// @Success 200 {object} []types.Resource
// @Failure 400 {object} map[string]string
// @Router /datasource/{id}/resources [get]
@@ -346,13 +347,14 @@ func (h *DataSourceHandler) ListAvailableResources(c *gin.Context) {
}
id := c.Param("id")
parentID := c.Query("parent_id")
if _, status, msg := h.getOwnedDataSource(ctx, tenantID, id); status != http.StatusOK {
c.JSON(status, gin.H{"error": msg})
return
}
resources, err := h.service.ListAvailableResources(ctx, id)
resources, err := h.service.ListAvailableResources(ctx, id, parentID)
if err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
return