Repository navigation
feat: Implement API of Server(data source connect_id patch) - #15264
whitepicker wants to merge 4 commits into
Conversation
|
Caution Review failedFailed to post review comments 📝 WalkthroughWalkthroughThis PR implements the connector update feature for the Go API server rewrite. It adds a PATCH ChangesConnector Update Feature
LLM Error Formatting Fix
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 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 99-105: The code currently treats payload["data"] that fails to
unmarshal into map[string]json.RawMessage as a no-op by falling back to
json.Marshal(payload); instead, when the "data" key exists but is not a JSON
object, modify the logic in this block (the code using payload, the "data"
variable, the dataObj map and json.Unmarshal) to return an explicit error
indicating a malformed "data" wrapper rather than returning
json.Marshal(payload). Keep the existing successful path (when json.Unmarshal
into dataObj succeeds) returning data, but if json.Unmarshal returns an error or
dataObj is nil, return a descriptive error (rather than marshalling the whole
payload) so callers can reject invalid client input.
In `@internal/service/connector.go`:
- Around line 197-209: The current latestDoneSyncState function calls
connectorDAO.GetLatestSyncLog(connectorID, datasetID, "sync") which returns the
newest log of any status and then ignores it unless Status == TaskStatusDone,
risking losing an earlier completed checkpoint; change the behaviour to query
for the most recent completed sync log directly (e.g., add or use a DAO method
that filters by status like GetLatestSyncLogByStatus or GetLatestSyncLog with an
explicit status="done" parameter) and return that record's PollRangeEnd and
TotalDocsIndexed in latestDoneSyncState instead of fetching an unfiltered latest
row and discarding non-done entries.
- Around line 212-235: The current flow (HasScheduledSyncLog -> UpdateByID ->
CreateSyncLog) is not atomic and can produce duplicate jobs or leave connector
status updated if CreateSyncLog fails; change this to perform the existence
check, status update (UpdateByID), and sync-log creation (CreateSyncLog) inside
a single database transaction via the connectorDAO transactional API (e.g.,
BeginTx/WithTx) so that on any error the transaction is rolled back;
alternatively implement an atomic upsert or INSERT ... WHERE NOT EXISTS at the
DAO level to ensure CreateSyncLog only succeeds once and UpdateByID is only
committed when the insert succeeds, and make sure errors trigger rollback and
return to the caller.
🪄 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: ed222bbd-c4b0-4397-a88e-0ddb3036d37f
📒 Files selected for processing (9)
build.shinternal/binding/rag_analyzer.gointernal/dao/connector.gointernal/entity/connector.gointernal/handler/connector.gointernal/handler/connector_test.gointernal/router/router.gointernal/service/connector.gointernal/service/llm.go
There was a problem hiding this comment.
🧹 Nitpick comments (1)
internal/service/connector.go (1)
116-118: 💤 Low valueRemove redundant
idfrom updates map.The
UpdateByIDmethod already receivesconnectorIDas a parameter and uses it in the WHERE clause. Addingidto the updates map is unnecessary and could cause confusion about whether the ID is being updated.Suggested fix
if len(updates) > 0 { - updates["id"] = connectorID if err := s.connectorDAO.UpdateByID(connectorID, updates); err != nil { return nil, common.CodeServerError, err }🤖 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 116 - 118, The updates map is incorrectly being assigned an "id" field before calling s.connectorDAO.UpdateByID(connectorID, updates); remove the line that sets updates["id"] = connectorID so the ID is only passed via the connectorID parameter to UpdateByID (leave the rest of the updates logic and the call to s.connectorDAO.UpdateByID intact).
🤖 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.
Nitpick comments:
In `@internal/service/connector.go`:
- Around line 116-118: The updates map is incorrectly being assigned an "id"
field before calling s.connectorDAO.UpdateByID(connectorID, updates); remove the
line that sets updates["id"] = connectorID so the ID is only passed via the
connectorID parameter to UpdateByID (leave the rest of the updates logic and the
call to s.connectorDAO.UpdateByID intact).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 9554ee4b-9940-4801-baae-1fdabbe11ede
📒 Files selected for processing (4)
internal/dao/connector.gointernal/handler/connector.gointernal/handler/connector_test.gointernal/service/connector.go
## 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
|
The feature is already implemented. |
Summary
Implemented the Go API endpoint:
PATCH /api/v1/connectors/:connector_idThis ports the Python behavior from
api/apps/restful_apis/connector_api.py::update_connectorinto the Go server.Related Issue
Closes: #15240
Change Type
Real Behavior Proof
The Go API now supports:
Example request:
{ "data": { "refresh_freq": 10, "prune_freq": 20, "timeout_secs": 180, "config": { "sync_deleted_files": true }, "status": "SCHEDULE" } }Expected behavior:
refresh_freqprune_freqtimeout_secsconfigChecklist
PATCH /api/v1/connectors/:connector_idalready existed in Go.connector_api.py.databody.--help.