Skip to content

feat(go-api): implement connector (data source) management endpoints - #15274

Merged
JinHai-CN merged 6 commits into
infiniflow:mainfrom
Lobster-0429:feat/go-api-connector-management
May 28, 2026
Merged

JinHai-CN merged 6 commits into
infiniflow:mainfrom
Lobster-0429:feat/go-api-connector-management

Conversation

@Lobster-0429

@Lobster-0429 Lobster-0429 commented May 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Ports the connector (data source) management endpoints that power web/src/pages/user-setting/data-source/ from Python
(api/apps/restful_apis/connector_api.py) to Go. Previously only GET /connectors (list) was implemented in Go; this adds the rest of the lifecycle.

Closes #15273 (subtask of #15240).

Endpoints implemented

All under base path /api/v1 (mirrors the Python routes):

Method Path Description
POST /connectors/{connector_id}/test Validate stored credentials

GET /connectors (list) was already present and is unchanged.

Implementation

Follows the existing handler → service → dao layering (per PR #14790):

  • entity (internal/entity/connector.go): added the SyncLogs.task_type column (selected by the Python sync-log query) and ConnectorTaskType / InputType constants mirroring common.constants.
  • dao (internal/dao/connector.go): added SyncLogsDAO (join-based ListByConnectorID, a HasScheduled guard, status updates, and delete) and Connector2KbDAO; reuses the existing ConnectorDAO CRUD.
  • service (internal/service/connector.go): added Create/Get/Update/Delete/ListLogs/Rebuild/Test, the accessible() tenant
    check, and cancelTasks/scheduleTasks helpers mirroring ConnectorService.cancel_tasks / schedule_tasks. Sentinel errors map cleanly to the Python response codes.
  • handler (internal/handler/connector.go): added the seven handlers with the same response shapes/codes as Python (including PATCH's {"data": {...}} envelope unwrap).
  • router (internal/router/router.go): registered the new routes under the /connectors group.

Known gaps vs. Python (no Go task-worker yet)

These are documented in code comments as follow-ups:

  • rebuild drops the existing sync logs and enqueues a reindex SYNC task, but does not delete previously indexed documents — FileService.delete_docs is not yet ported to Go. The re-sync will re-ingest from the source; stale docs
    are not removed here.
  • test gates on source == rest_api and credential presence only. The per-connector validate_config path lives in the Python common.data_source package and has no Go equivalent yet.

Provider OAuth web flows (google/gmail/google-drive/box) remain out of scope ppr the issue and should be a separate subtask.

Testing

  • Added internal/service/connector_test.go covering the pure helpers (connectorPruneEnabled, isCancelStatus, isScheduleStatus).
  • No Go toolchain was available in the dev environment, so go build ./... and go vet ./... verification is left to CI.

@dosubot dosubot Bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label May 27, 2026
@coderabbitai

coderabbitai Bot commented May 27, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR implements the POST /connectors/{connector_id}/test endpoint to validate connector credentials. It adds service-layer authorization, credential validation, and sentinel errors; maps those errors to standardized HTTP responses in the handler; registers the new endpoint; and provides test coverage via table-driven test cases.

Changes

Connector Test Endpoint

Layer / File(s) Summary
Service Contract: Sentinel Errors and TestConnector Method
internal/service/connector.go
Defines ErrConnectorNotFound, ErrConnectorNoAuth, and ErrConnectorTestUnsupported sentinel errors for consistent error reporting. Implements TestConnector(connectorID, userID) with tenant authorization via accessible() helper, validates connector source is "rest_api", requires non-empty credentials in stored config, and returns sentinel errors for not-found/unauthorized/unsupported cases.
Handler Interface and Error Mapping
internal/handler/connector.go
Updates connectorServiceIface to include TestConnector method. Adds connectorErrorResponse() helper to map the three sentinel errors to standardized JSON payloads with code/data/message structure, falling back to server-error for unrecognized failures.
HTTP Handler and Endpoint Registration
internal/handler/connector.go, internal/router/router.go
Implements TestConnector() HTTP handler to validate non-empty connector_id, call service method, return success (HTTP 200, CodeSuccess, data: true) or mapped error responses via connectorErrorResponse, and register POST /:connector_id/test in the protected /api/v1/connectors route group.
Handler Test Coverage
internal/handler/connector_test.go
Updates fakeConnectorService to return empty ListConnectorsResponse, support configurable TestConnector error, and conditionally return error in CreateConnector. Implements TestConnectorHandlerTestConnector with table-driven test cases exercising success and sentinel error paths, verifies HTTP 200 status and response code in JSON, and improves assertion messages to include expected values.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested labels

size:XL

Suggested reviewers

  • Haruko386

Poem

🐰 A test endpoint hops into place,
Auth checks and credentials embrace,
Sentinel errors guide the way,
REST API connectors test today,
JSON responses neatly trace!

🚥 Pre-merge checks | ✅ 1 | ❌ 4

❌ Failed checks (3 warnings, 1 inconclusive)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The changeset implements only the POST /connectors/{id}/test endpoint for validating credentials, but the linked issue #15273 requires seven endpoints total (POST/GET/PATCH/DELETE /connectors, GET /logs, POST /rebuild, POST /test). Either implement all seven required endpoints or open separate subtasks for the missing endpoints (Create, Get, Update, Delete, ListLogs, Rebuild). Clarify scope in the PR description.
Out of Scope Changes check ⚠️ Warning The changeset includes changes to internal/handler/connector.go that remove GetConnector and CreateConnector methods, which appear to be scope modifications beyond the single test endpoint implementation described. Clarify whether the removal of GetConnector and CreateConnector is intentional (possibly replacing them with new implementations) or if these removals were out-of-scope. Document the rationale for these deletions.
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title references the feature implemented (connector management endpoints) but does not specify which endpoints or the key action (POST /connectors/{id}/test) being added in this particular changeset. Consider using a more specific title that highlights the primary endpoint being implemented, such as 'feat(go-api): add connector test endpoint' or similar to clarify the main changeset focus.
✅ Passed checks (1 passed)
Check name Status Explanation
Description check ✅ Passed The PR description is comprehensive and follows the template structure, clearly explaining the problem solved, implementation details, and known gaps. It includes the required type-of-change context and closure of linked issue #15273.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Port the connector lifecycle endpoints that power the user-setting data
source page from Python (api/apps/restful_apis/connector_api.py) to Go.
Previously only GET /connectors (list) was implemented.

New endpoints under /api/v1/connectors:
- POST   /connectors                  create
- GET    /connectors/:id              get one
- PATCH  /connectors/:id              update (config/freqs + reschedule/cancel)
- DELETE /connectors/:id              delete (cancels sync tasks first)
- GET    /connectors/:id/logs         list sync logs (paginated)
- POST   /connectors/:id/rebuild      schedule a full re-sync
- POST   /connectors/:id/test         validate stored credentials

Layering follows the existing handler -> service -> dao pattern:
- entity: add SyncLogs.task_type column + ConnectorTaskType/InputType consts
- dao: add SyncLogsDAO (list_sync_tasks join, schedule guard, status updates,
  delete) and Connector2KbDAO; reuse existing ConnectorDAO CRUD
- service: add Create/Get/Update/Delete/ListLogs/Rebuild/Test plus the
  accessible() tenant check and cancel/schedule task helpers mirroring
  ConnectorService.cancel_tasks / schedule_tasks
- router: register the new routes under the /connectors group

Known gaps vs. Python (no Go task-worker yet):
- rebuild does not delete previously indexed documents (FileService.delete_docs
  is not ported); it drops sync logs and enqueues a reindex SYNC task.
- test only gates on source == rest_api and credential presence; the
  per-connector validate_config path lives in common.data_source (Python-only).
Both are noted in code comments as follow-ups.

OAuth web flows (google/gmail/drive/box) remain out of scope per the issue.

Refs infiniflow#15273
@Lobster-0429
Lobster-0429 force-pushed the feat/go-api-connector-management branch from 22c0a13 to ebd725d Compare May 27, 2026 02:25
@Lobster-0429

Copy link
Copy Markdown
Contributor Author

Hi, @JinHai-CN ,
Please review this PR.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/handler/connector.go`:
- Around line 358-361: The current branch treats any error that's not
service.ErrConnectorNoAuth or service.ErrConnectorNotFound as a validation error
and returns gin.H{"code": common.CodeDataError, "data": false, ...}, which masks
true server-side failures; change the logic in the connector error handling so
only explicit validation sentinel errors (e.g., a new or existing specific
validation error sentinel like service.ErrConnectorValidation or whatever
validation errors your service returns) map to common.CodeDataError with
data=false, and for any other unknown error delegate to connectorErrorResponse
(preserving its existing server-error handling). Locate the block checking
errors.Is(err, service.ErrConnectorNoAuth) / service.ErrConnectorNotFound and
replace the broad fallback with an explicit validation-errors check, returning
CodeDataError only for those validation sentinels and calling
connectorErrorResponse(c, err) for all other errors.
- Around line 267-278: The page_size query parsing currently allows any positive
integer which can cause heavy DB/load spikes; update the parsing near the
pageSize logic to enforce a server-side maximum (e.g. const maxPageSize = 100)
and clamp the parsed value using something like pageSize = min(parsedPageSize,
maxPageSize) (keep the existing behavior for empty/invalid values and positive
checks), referencing the pageSize variable and c.Query("page_size") so the
handler never uses an unbounded page size.

In `@internal/service/connector.go`:
- Around line 95-98: In the accessible method, don't collapse every
s.connectorDAO.GetByID error into ErrConnectorNotFound; instead call conn, err
:= s.connectorDAO.GetByID(connectorID) and if err != nil use errors.Is(err,
ErrConnectorNotFound) (or compare the DAO's not-found sentinel) to return
(false, ErrConnectorNotFound) only for true not-found cases, and return (false,
err) for any other DB/infra errors so callers can distinguish real errors from
missing-resource cases.
- Around line 402-405: The connector lookup error in cancelTasks and
scheduleTasks is being swallowed—when s.connectorDAO.GetByID(connectorID) fails
the functions return nil (success); change both functions to propagate and
return the lookup error (or a wrapped/contextual error) instead of nil so
callers see the failure; locate the GetByID check in cancelTasks and
scheduleTasks (and the similar check around the other occurrence at the second
block referencing s.connectorDAO.GetByID) and replace the `return nil` with
`return err` (or fmt.Errorf("connector lookup failed: %w", err)) so precheck
failures signal an error to callers.
- Around line 345-350: Before calling s.syncLogsDAO.DeleteByConnectorAndKb and
s.scheduleSync in Rebuild, validate that the given kbID is actually linked to
the connectorID: query the connector-to-KB mapping (e.g., use the connector DAO
or an existing method that returns KBs for a connector) and if kbID is not
present return an error; only then call
s.syncLogsDAO.DeleteByConnectorAndKb(connectorID, kbID) and
s.scheduleSync(connectorID, kbID, true, entity.ConnectorTaskTypeSync). This
prevents deleting/scheduling for KBs not associated with the connector.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c24c56d7-3fdf-41af-8fca-b19c47d430cd

📥 Commits

Reviewing files that changed from the base of the PR and between 8f0632c and ebd725d.

📒 Files selected for processing (6)
  • internal/dao/connector.go
  • internal/entity/connector.go
  • internal/handler/connector.go
  • internal/router/router.go
  • internal/service/connector.go
  • internal/service/connector_test.go

Comment thread internal/handler/connector.go Resolved
Comment thread internal/handler/connector.go Resolved
Comment thread internal/service/connector.go Resolved
Comment thread internal/service/connector.go Resolved
Comment thread internal/service/connector.go Resolved
@tmimmanuel tmimmanuel mentioned this pull request May 27, 2026
1 of 6 tasks
…or-management

# Conflicts:
#	internal/handler/connector.go
#	internal/router/router.go
#	internal/service/connector.go

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
internal/handler/connector.go (1)

114-129: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Unify CreateConnector validation before Gin's required-field binding fires.

ShouldBindJSON(&req) is still binding into service.CreateConnectorRequest, which has binding:"required" on name and source in internal/service/connector.go:137-145. That means omitted fields still return the 400 "Invalid request body" path before these Python-style CodeDataError checks run, while "config": {} also slips through because empty objects unmarshal to a non-nil map. If this endpoint is meant to mirror the Python validation envelope, bind into a handler-local struct and validate trimmed name/source plus len(config) > 0 here.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/handler/connector.go` around lines 114 - 129, The CreateConnector
handler currently uses c.ShouldBindJSON(&service.CreateConnectorRequest) which
triggers Gin's binding:"required" checks before your custom CodeDataError paths;
instead define a handler-local request struct (matching fields Name, Source,
Config) and call c.ShouldBindJSON into that local struct, then perform manual
validation: trim Name and Source and return CodeDataError if empty, and ensure
Config is non-nil and has len(config) > 0 (reject empty objects), only after
these checks map/convert to service.CreateConnectorRequest and continue; update
references to ShouldBindJSON, CreateConnector, and
service.CreateConnectorRequest accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@internal/handler/connector.go`:
- Around line 114-129: The CreateConnector handler currently uses
c.ShouldBindJSON(&service.CreateConnectorRequest) which triggers Gin's
binding:"required" checks before your custom CodeDataError paths; instead define
a handler-local request struct (matching fields Name, Source, Config) and call
c.ShouldBindJSON into that local struct, then perform manual validation: trim
Name and Source and return CodeDataError if empty, and ensure Config is non-nil
and has len(config) > 0 (reject empty objects), only after these checks
map/convert to service.CreateConnectorRequest and continue; update references to
ShouldBindJSON, CreateConnector, and service.CreateConnectorRequest accordingly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 45481349-60f2-49cd-9da7-5aef6f4bc061

📥 Commits

Reviewing files that changed from the base of the PR and between ebd725d and fb33237.

📒 Files selected for processing (3)
  • internal/entity/connector.go
  • internal/handler/connector.go
  • internal/router/router.go
💤 Files with no reviewable changes (1)
  • internal/router/router.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • internal/entity/connector.go

@Haruko386 Haruko386 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @web-dev0521, we have implement in #15300

Method Path Description
POST /connectors Create a connector
GET /connectors/{connector_id} Get one connector (config + sync state)
PATCH /connectors/{connector_id} Update config/freqs; reschedule or cancel tasks
DELETE /connectors/{connector_id} Delete (cancels sync tasks first)
GET /connectors/{connector_id}/logs List sync logs (paginated)
POST /connectors/{connector_id}/rebuild Schedule a full re-sync
POST /connectors/{connector_id}/test Validate stored credentials

Just keep : /connectors/{connector_id}/test plz
Read #15240 for more info

…ed by infiniflow#15300

Per reviewer request, remove Create, Get, Update, Delete, ListLogs, and Rebuild
connector endpoints (already implemented in infiniflow#15300). Keep only POST
/:connector_id/test which is not covered there.

- handler: remove all methods except ListConnectors and TestConnector; introduce
  connectorServiceIface for testability; update test to cover TestConnector cases
- service: remove CreateConnector, UpdateConnector, DeleteConnector, ListLogs,
  Rebuild, and all scheduling/task helpers; keep accessible and TestConnector
- dao: remove SyncLogsDAO and Connector2KbDAO (no longer used)
- entity: remove ConnectorTaskType and ConnectorInputType constants
- router: remove all connector routes except GET / and POST /:id/test
@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:XL This PR changes 500-999 lines, ignoring generated files. labels May 28, 2026
@Lobster-0429

Copy link
Copy Markdown
Contributor Author

Hi, @Haruko386 ,
Thank you for your review. I just removed implemented APIs.
Please review again.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
internal/service/connector.go (1)

130-133: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Avoid collapsing all connector lookup failures to not-found in TestConnector.

Line 130-133 currently converts any DAO failure into ErrConnectorNotFound, so transient/storage failures are misreported as missing connectors.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/service/connector.go` around lines 130 - 133, The code collapses any
error from s.connectorDAO.GetByID(connectorID) into ErrConnectorNotFound; change
it to distinguish a genuine "not found" from other failures by checking the
concrete error (e.g., errors.Is(err, dao.ErrNotFound) or errors.Is(err,
sql.ErrNoRows)) and only return ErrConnectorNotFound in that case, otherwise
return or wrap the original error (e.g., fmt.Errorf("fetch connector: %w", err))
so transient/storage failures are propagated instead of misreported; ensure you
import errors (and dao/sql sentinel) as needed and leave the
ErrConnectorNotFound return path only for true missing-connector cases.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@internal/service/connector.go`:
- Around line 130-133: The code collapses any error from
s.connectorDAO.GetByID(connectorID) into ErrConnectorNotFound; change it to
distinguish a genuine "not found" from other failures by checking the concrete
error (e.g., errors.Is(err, dao.ErrNotFound) or errors.Is(err, sql.ErrNoRows))
and only return ErrConnectorNotFound in that case, otherwise return or wrap the
original error (e.g., fmt.Errorf("fetch connector: %w", err)) so
transient/storage failures are propagated instead of misreported; ensure you
import errors (and dao/sql sentinel) as needed and leave the
ErrConnectorNotFound return path only for true missing-connector cases.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d0184934-11c3-4152-84df-570bd24b4b3f

📥 Commits

Reviewing files that changed from the base of the PR and between fb33237 and 4fdd6a1.

📒 Files selected for processing (6)
  • internal/dao/connector.go
  • internal/entity/connector.go
  • internal/handler/connector.go
  • internal/handler/connector_test.go
  • internal/router/router.go
  • internal/service/connector.go
💤 Files with no reviewable changes (3)
  • internal/router/router.go
  • internal/entity/connector.go
  • internal/dao/connector.go

JinHai-CN pushed a commit that referenced this pull request May 28, 2026
## Summary
- Add Go REST support for `GET /api/v1/system/healthz`.
- Return Python-compatible `ok`/`nok` dependency fields for DB, Redis,
document engine, and storage.
- Return HTTP 200 only when all checks pass; otherwise return HTTP 500
with `_meta` failure details.
- Add focused service coverage for the unhealthy dependency response
when Go dependencies are not initialized.

## Scope
This is a small, isolated slice of #15240. It avoids current open
connector PRs (#15274, #15300, #15265, #15264), tenant/member PRs
(#15295, #15301, #15276), MCP PRs (#15281, #15253, #15254, #15260,
#15261, #15262), and the memory-message PR (#15256).

Refs #15240
@Lobster-0429

Copy link
Copy Markdown
Contributor Author

Hi, @JinHai-CN ,
Could you please review this PR?

@Lobster-0429
Lobster-0429 requested a review from Haruko386 May 28, 2026 06:16

@Haruko386 Haruko386 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@web-dev0521 LGTM

Comment thread internal/dao/connector.go
func (dao *ConnectorDAO) DeleteByID(id string) error {
return DB.Where("id = ?", id).Delete(&entity.Connector{}).Error
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label May 28, 2026
@Haruko386 Haruko386 added the ci Continue Integration label May 28, 2026
@Lobster-0429

Copy link
Copy Markdown
Contributor Author

Hi, @yingfeng ,
Could you please review this PR?

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
internal/router/router.go (1)

317-321: ⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

Connector route surface is incomplete for /api/v1/connectors and risks API regression.

Line 319–320 only expose list + test. The objective requires create/get/patch/delete/logs/rebuild/test under /api/v1/connectors. If create/get (and others) were removed here, clients using the Data Source settings APIs will break.

Please restore/register the missing connector routes in this group (or keep them until full parity lands in the same release unit).

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/router/router.go` around lines 317 - 321, The connector route group
currently only registers ListConnectors and TestConnector, which removes other
required endpoints; update the v1.Group("/connectors") block to register the
full surface by adding routes that map POST "/" to
r.connectorHandler.CreateConnector, GET "/:connector_id" to
r.connectorHandler.GetConnector, PATCH "/:connector_id" to
r.connectorHandler.PatchConnector, DELETE "/:connector_id" to
r.connectorHandler.DeleteConnector, GET "/:connector_id/logs" to
r.connectorHandler.ConnectorLogs, POST "/:connector_id/rebuild" to
r.connectorHandler.RebuildConnector, and ensure the existing GET "/" and POST
"/:connector_id/test" remain wired to ListConnectors and TestConnector
respectively so clients keep full parity.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@internal/router/router.go`:
- Around line 317-321: The connector route group currently only registers
ListConnectors and TestConnector, which removes other required endpoints; update
the v1.Group("/connectors") block to register the full surface by adding routes
that map POST "/" to r.connectorHandler.CreateConnector, GET "/:connector_id" to
r.connectorHandler.GetConnector, PATCH "/:connector_id" to
r.connectorHandler.PatchConnector, DELETE "/:connector_id" to
r.connectorHandler.DeleteConnector, GET "/:connector_id/logs" to
r.connectorHandler.ConnectorLogs, POST "/:connector_id/rebuild" to
r.connectorHandler.RebuildConnector, and ensure the existing GET "/" and POST
"/:connector_id/test" remain wired to ListConnectors and TestConnector
respectively so clients keep full parity.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: fde18225-023d-4d68-b202-17d75d410a7b

📥 Commits

Reviewing files that changed from the base of the PR and between 4fdd6a1 and e9cffa1.

📒 Files selected for processing (1)
  • internal/router/router.go

Upstream PR infiniflow#15300 merged the Get/List/Delete/Rebuild/ListLog connector
endpoints and our branch keeps only the Test endpoint, so the merge had
to interleave handlers, tests, services, and DAO additions.

Resolved conflicts by keeping every method from both sides:

- internal/router/router.go: keep upstream's GET/POST/DELETE routes
  plus our POST /:connector_id/test route on the connectors group
- internal/handler/connector.go: union the connectorServiceIface
  methods (ListConnectors, CreateConnector, GetConnector, ListLog,
  DeleteConnector, RebuildConnector, TestConnector); union the
  handler functions; consolidate imports (errors, net/http, strconv,
  strings, common, entity, service)
- internal/handler/connector_test.go: union fakeConnectorService
  fields and methods so it satisfies the wider interface; add the
  missing CreateConnector method; keep both
  TestConnectorHandlerTestConnector and the upstream Delete/ListLogs
  tests
- internal/service/connector.go: keep upstream's CreateConnectorRequest,
  RebuildConnectorRequest, canAccessConnector, cancelConnectorTasks,
  CreateConnector, GetConnector, DeleteConnector, RebuildConnector,
  deleteConnectorDocumentChunks, ListLog AND our accessible +
  TestConnector
- internal/dao/connector.go: keep upstream's CancelRunningOrScheduledLogs,
  ListDocumentsByKBAndSourceType, RebuildConnector,
  createRebuildSyncLog, ListLogsByConnectorID
The previous merge dropped the `common`, `gorm.io/gorm` imports and
the connector constants block (`connectorInputTypePoll`,
`connectorStatusUnstarted`, `defaultConnectorFreq`,
`defaultConnectorTimeout`) when reconciling our TestConnector
additions with upstream's CRUD/log/rebuild additions. The file still
references all of them, so `go build cmd/server_main.go` failed in
~8s on the self-hosted CI runner.

- Re-add `gorm.io/gorm` and `ragflow/internal/common` imports.
- Re-add the connector constants block above the sentinel vars.
- Remove the leftover `Rebuild()` panic stub that was superseded by
  upstream's full `RebuildConnector(...)` method.
@codecov

codecov Bot commented May 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.16%. Comparing base (b7d88f0) to head (c4df2f7).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #15274   +/-   ##
=======================================
  Coverage   93.16%   93.16%           
=======================================
  Files          10       10           
  Lines         717      717           
  Branches      118      118           
=======================================
  Hits          668      668           
  Misses         29       29           
  Partials       20       20           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Lobster-0429

Copy link
Copy Markdown
Contributor Author

Hi, @JinHai-CN ,
Could you please review this PR?

@JinHai-CN
JinHai-CN merged commit f80ec17 into infiniflow:main May 28, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Subtask]: Go API — Data Source (Connector) management for the user-setting Data Source page

3 participants