Skip to content

fix(go): uploaded documents should be enabled by default - #16674

Merged
wangq8 merged 3 commits into
infiniflow:mainfrom
euvre:fix/go-upload-document-default-enabled-1
Jul 6, 2026
Merged

wangq8 merged 3 commits into
infiniflow:mainfrom
euvre:fix/go-upload-document-default-enabled-1

Conversation

@euvre

@euvre euvre commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This PR fixes a bug in the Go backend where newly uploaded documents in a dataset were created with Status set 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:
    • In CreateDocument, changed the default document Status from "0" to "1".
    • In newDatasetDocument, changed the default document Status from "0" to "1" and renamed the local variable from zero to run/status to make the intent explicit.

Verification

  • Started the Go backend (admin, API, ingestor) and the frontend with API_PROXY_SCHEME=go.
  • Logged in as [email protected] / 1.
  • Confirmed the issue existed: an existing file showed the Enable toggle in the OFF position.
  • Uploaded a new file after the fix and confirmed the Enable toggle is now ON by default.
  • Built the Go binaries with bash build.sh --go and ran bash build.sh --test ./internal/service/... successfully.

Notes

  • web/.env.development was changed to API_PROXY_SCHEME=go for local Go-mode testing but is intentionally left unstaged and not included in this commit.

euvre added 2 commits July 6, 2026 16:20
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.
@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. 🐞 bug Something isn't working, pull request that fix bug. labels Jul 6, 2026
@euvre euvre added the ci Continue Integration label Jul 6, 2026
@coderabbitai

coderabbitai Bot commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Document creation in internal/service/document.go now initializes Status to "1" for both direct and derived documents, while derived documents still initialize Run to "0".

Changes

Document Status Handling

Layer / File(s) Summary
Status initialization
internal/service/document.go
CreateDocument now sets Status to "1", and newDatasetDocument initializes Run to "0" while setting Status to "1".

Estimated code review effort: 1 (Trivial) | ~5 minutes

Poem

I nibbled one little status seed,
And tucked it where the docs all feed.
Run stays zero, status gleams bright,
Hoppy little defaults feel just right. 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly matches the main change: uploaded documents now default to enabled.
Description check ✅ Passed The description includes the required Summary and adds useful changes, verification, and notes details.

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.

@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.

🧹 Nitpick comments (1)
internal/service/document.go (1)

572-572: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Simplify string-pointer construction; avoid IIFE.

The inline closure is unnecessary — a local variable (as used in newDatasetDocument a 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

📥 Commits

Reviewing files that changed from the base of the PR and between 69966ac and 988f92b.

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

@wangq8
wangq8 merged commit bfb9641 into infiniflow:main Jul 6, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants