Repository navigation
fix(go): uploaded documents should be enabled by default - #16674
Conversation
Sets the default status to "1" (enabled) in newDatasetDocument so files uploaded to the Go backend are no longer disabled by default. Fixes: default upload status was "0", causing documents to appear as disabled in the dataset document list. ci
Include the document status in the upload response so the dataset table shows newly uploaded files as enabled (status=1) instead of defaulting to disabled when the field is missing. Closes the issue shown in the Feishu20260706-160252.gif recording.
📝 WalkthroughWalkthroughDocument creation in ChangesDocument Status Handling
Estimated code review effort: 1 (Trivial) | ~5 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
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.
🧹 Nitpick comments (1)
internal/service/document.go (1)
572-572: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winSimplify string-pointer construction; avoid IIFE.
The inline closure is unnecessary — a local variable (as used in
newDatasetDocumenta few hundred lines below) is simpler and more idiomatic.♻️ Proposed simplification
+ status := "1" document := &entity.Document{ ID: common.GenerateUUID(), Name: &req.Name, KbID: req.KbID, ParserID: req.ParserID, ParserConfig: entity.JSONMap{}, CreatedBy: req.CreatedBy, Type: req.Type, SourceType: req.Source, Suffix: ".doc", - Status: func() *string { s := "1"; return &s }(), + Status: &status, }🤖 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/document.go` at line 572, The Status field in this document builder is creating a string pointer with an unnecessary inline closure; replace that IIFE with the simpler local-variable pattern used in newDatasetDocument so the pointer is constructed in a more idiomatic way. Update the Status assignment in the relevant document construction logic in document.go to use a named local string variable and take its address, keeping the behavior unchanged.
🤖 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/document.go`:
- Line 572: The Status field in this document builder is creating a string
pointer with an unnecessary inline closure; replace that IIFE with the simpler
local-variable pattern used in newDatasetDocument so the pointer is constructed
in a more idiomatic way. Update the Status assignment in the relevant document
construction logic in document.go to use a named local string variable and take
its address, keeping the behavior unchanged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 0ad350f4-2d93-4534-addd-5a72147e357c
📒 Files selected for processing (1)
internal/service/document.go
Summary
This PR fixes a bug in the Go backend where newly uploaded documents in a dataset were created with
Statusset to"0"(disabled). As a result, users had to manually enable every uploaded file before it could be used for retrieval or chat, which is inconsistent with the expected behavior.Changes
internal/service/document.go:CreateDocument, changed the default documentStatusfrom"0"to"1".newDatasetDocument, changed the default documentStatusfrom"0"to"1"and renamed the local variable fromzerotorun/statusto make the intent explicit.Verification
API_PROXY_SCHEME=go.[email protected]/1.bash build.sh --goand ranbash build.sh --test ./internal/service/...successfully.Notes
web/.env.developmentwas changed toAPI_PROXY_SCHEME=gofor local Go-mode testing but is intentionally left unstaged and not included in this commit.