Skip to content

feat: Implement API of ragflow server in Go - #15256

Merged
xugangqiang merged 8 commits into
infiniflow:mainfrom
jonathanchang31:feat/implement-api-ragflow-server
Jun 10, 2026
Merged

xugangqiang merged 8 commits into
infiniflow:mainfrom
jonathanchang31:feat/implement-api-ragflow-server

Conversation

@jonathanchang31

@jonathanchang31 jonathanchang31 commented May 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Implemented the Go API endpoint for Memory message forgetting:
    • DELETE /api/v1/messages/{memory_id}:{message_id}
  • Added route registration for the Memory message DELETE endpoint only.
  • Added request path validation for memory_id:message_id.
  • Added service logic to mark a message as forgotten by setting forget_at.
  • Preserved Python-compatible response behavior:
    • Success returns code: 0, message: true, data: null.
  • Added focused unit tests for message path parsing and invalid message ID handling.
  • Fixed Linux cgo linker config to use the installed shared PCRE2 library so Go tests/builds can run in this environment.

Related Issue

Closes: #15240

Change Type

  • Feature
  • Test
  • Build / CI compatibility

Implemented API

  • DELETE /api/v1/messages/{memory_id}:{message_id}

Real Behavior Proof

Validated with targeted Go tests:

/tmp/go1.25.0/bin/go test ./internal/handler ./internal/router

Result:

ok  	ragflow/internal/handler
?   	ragflow/internal/router	[no test files]

Validated server entrypoint build:

/tmp/go1.25.0/bin/go build -o /tmp/ragflow-server-main ./cmd/server_main.go

Result:

build succeeded

Validated patch formatting:

git diff --check

Result:

no whitespace errors

Checklist

  • Implemented only DELETE /api/v1/messages/{memory_id}:{message_id}.
  • Did not implement unrelated Memory message APIs.
  • Added route registration.
  • Added handler validation.
  • Added service-level memory access check.
  • Added tests.
  • Ran targeted Go tests.
  • Ran server build validation.
  • Ran git diff --check.

@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. 💞 feature Feature request, pull request that fullfill a new feature. 🧪 test Pull requests that update test cases. labels May 26, 2026
@coderabbitai

coderabbitai Bot commented May 26, 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

Adds DELETE /api/v1/messages/{memory_id}:{message_id}: service ForgetMessage with access checks and doc-engine update, handler parsing/error mapping and tests, router registration for the endpoint, plus a cgo linker flag change to use -lpcre2-8.

Changes

Forget Message API Feature

Layer / File(s) Summary
Service — docEngine init, ResourceNotFound, ForgetMessage
internal/service/memory.go
MemoryService adds docEngine (initialized in NewMemoryService()), introduces exported ResourceNotFoundError, and implements ForgetMessage(ctx, userID, memoryID, messageID) which authorizes access and updates forget_at / forget_at_flt for doc id {memoryID}_{messageID} in index memory_{tenantID}.
Handler, parser, error mapping, and tests
internal/handler/memory.go, internal/handler/memory_message_test.go
Implements MemoryHandler.ForgetMessage: authenticates, parses combined memory_id:message_id via parseMemoryMessagePath, calls memoryService.ForgetMessage, maps ResourceNotFoundError to CodeNotFound, maps other errors to CodeServerError, and returns success. Adds isMemoryServiceNotFound, parser helper, and tests for parser and malformed-path handling.
Router registration and comment alignment
internal/router/router.go
Registers DELETE /api/v1/messages/:memory_message mapped to memoryHandler.ForgetMessage under protected v1 API and adjusts comment/whitespace alignment for internal tenant endpoints.

Linker flag update

Layer / File(s) Summary
Binding cgo linker flag
internal/binding/rag_analyzer.go
Linux #cgo LDFLAGS now use -lpcre2-8 instead of an explicit static /usr/lib/.../libpcre2-8.a archive.
sequenceDiagram
  participant Client as Client(API Request)
  participant Handler as MemoryHandler
  participant Service as MemoryService
  participant Require as requireMemoryAccess
  participant DocEngine as DocEngine(Index)
  Client->>Handler: DELETE /api/v1/messages/{memory_id}:{message_id}
  Handler->>Service: ForgetMessage(ctx, userID, memoryID, messageID)
  Service->>Require: requireMemoryAccess(ctx, userID, memoryID)
  Require-->>Service: allowed / denied
  Service->>DocEngine: Update index "memory_{tenantID}" set forget_at / forget_at_flt for "{memoryID}_{messageID}"
  DocEngine-->>Service: update result
  Service-->>Handler: success or ResourceNotFoundError / other error
  Handler-->>Client: HTTP 200 or mapped error
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 I split the path with a colon bright,

memory then message, parsed just right.
A forget_at stamp on the chunk I store,
tests hop along and check the door.
Link flags neat — the build hums more.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 6.25% 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 'feat: Implement API of ragflow server in Go' is vague and overly broad; it refers generally to ragflow server API implementation but does not specify the particular endpoint or focused change (DELETE /api/v1/messages endpoint). Consider a more specific title like 'feat: Implement DELETE /api/v1/messages endpoint for memory message forgetting' to clearly indicate the primary change.
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The PR successfully implements the DELETE /api/v1/messages/{memory_id}:{message_id} endpoint as specified in issue #15240, including route registration, handler validation, service-level access checks, and targeted unit tests while maintaining Python-compatible responses.
Out of Scope Changes check ✅ Passed All changes are directly related to the stated objectives: implementing the DELETE messages endpoint, supporting infrastructure (route/handler/service), and necessary build fixes (PCRE2 linker config). No unrelated changes detected.
Description check ✅ Passed The PR description comprehensively covers the problem, change type, API endpoint implemented, validation evidence, and implementation details with a detailed checklist.

✏️ 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.

@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: 1

🤖 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/system.go`:
- Around line 219-252: The handler currently ignores req.PkgName and always
calls common.SetLevel(level) and mutates config.Log.Level; change it to validate
req.PkgName against the supported package list (or allowed package map) before
applying any changes, and if the name is unknown return a 400 with a clear
message; if you support per-package levels, route the change to the
package-specific setter instead of calling common.SetLevel (or document that
only a special global name like "global" is accepted) and only update
server.GetConfig().Log.Level when the pkg name denotes the global logger. Ensure
you reference and check req.PkgName, common.SetLevel, and
server.GetConfig().Log.Level in the implementation.
🪄 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: 29942f7e-f440-43ad-9497-0a8093769d19

📥 Commits

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

📒 Files selected for processing (6)
  • internal/binding/rag_analyzer.go
  • internal/handler/system.go
  • internal/handler/system_test.go
  • internal/router/router.go
  • internal/service/llm.go
  • internal/service/system.go

Comment thread internal/handler/system.go Outdated
Comment on lines +219 to +252
var req struct {
PkgName string `json:"pkg_name" binding:"required"`
Level string `json:"level" binding:"required"`
}
if err := c.ShouldBindJSON(&req); err != nil {
c.JSON(http.StatusBadRequest, gin.H{
"code": 400,
"message": "pkg_name and level are required",
})
return
}

level := normalizeLogLevel(req.Level)
if err := common.SetLevel(level); err != nil {
c.JSON(http.StatusBadRequest, gin.H{
"code": 400,
"message": "Invalid log level: " + req.Level,
})
return
}

config := server.GetConfig()
if config != nil {
config.Log.Level = level
}

c.JSON(http.StatusOK, gin.H{
"code": 0,
"message": "success",
"data": gin.H{
"pkg_name": req.PkgName,
"level": req.Level,
},
})

@coderabbitai coderabbitai Bot May 26, 2026 •

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.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Validate pkg_name before applying global log level.

SetConfigLogLevel accepts any pkg_name but always mutates one global logger level. This can return false-positive success for unsupported package targets. Please reject unknown package names (or explicitly scope behavior) to avoid contract drift.

Proposed fix
 func (h *SystemHandler) SetConfigLogLevel(c *gin.Context) {
 	var req struct {
 		PkgName string `json:"pkg_name" binding:"required"`
 		Level   string `json:"level" binding:"required"`
 	}
@@
+	if req.PkgName != "ragflow" {
+		c.JSON(http.StatusBadRequest, gin.H{
+			"code":    400,
+			"message": "unsupported pkg_name: " + req.PkgName,
+		})
+		return
+	}
+
 	level := normalizeLogLevel(req.Level)
 	if err := common.SetLevel(level); err != nil {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
var req struct {
PkgName string `json:"pkg_name" binding:"required"`
Level string `json:"level" binding:"required"`
}
if err := c.ShouldBindJSON(&req); err != nil {
c.JSON(http.StatusBadRequest, gin.H{
"code": 400,
"message": "pkg_name and level are required",
})
return
}
level := normalizeLogLevel(req.Level)
if err := common.SetLevel(level); err != nil {
c.JSON(http.StatusBadRequest, gin.H{
"code": 400,
"message": "Invalid log level: " + req.Level,
})
return
}
config := server.GetConfig()
if config != nil {
config.Log.Level = level
}
c.JSON(http.StatusOK, gin.H{
"code": 0,
"message": "success",
"data": gin.H{
"pkg_name": req.PkgName,
"level": req.Level,
},
})
var req struct {
PkgName string `json:"pkg_name" binding:"required"`
Level string `json:"level" binding:"required"`
}
if err := c.ShouldBindJSON(&req); err != nil {
c.JSON(http.StatusBadRequest, gin.H{
"code": 400,
"message": "pkg_name and level are required",
})
return
}
if req.PkgName != "ragflow" {
c.JSON(http.StatusBadRequest, gin.H{
"code": 400,
"message": "unsupported pkg_name: " + req.PkgName,
})
return
}
level := normalizeLogLevel(req.Level)
if err := common.SetLevel(level); err != nil {
c.JSON(http.StatusBadRequest, gin.H{
"code": 400,
"message": "Invalid log level: " + req.Level,
})
return
}
config := server.GetConfig()
if config != nil {
config.Log.Level = level
}
c.JSON(http.StatusOK, gin.H{
"code": 0,
"message": "success",
"data": gin.H{
"pkg_name": req.PkgName,
"level": req.Level,
},
})
🤖 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/system.go` around lines 219 - 252, The handler currently
ignores req.PkgName and always calls common.SetLevel(level) and mutates
config.Log.Level; change it to validate req.PkgName against the supported
package list (or allowed package map) before applying any changes, and if the
name is unknown return a 400 with a clear message; if you support per-package
levels, route the change to the package-specific setter instead of calling
common.SetLevel (or document that only a special global name like "global" is
accepted) and only update server.GetConfig().Log.Level when the pkg name denotes
the global logger. Ensure you reference and check req.PkgName, common.SetLevel,
and server.GetConfig().Log.Level in the implementation.

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.

@jonathanchang31 fix this

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.

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

@jonathanchang31
jonathanchang31 force-pushed the feat/implement-api-ragflow-server branch from 09bfc89 to 231e9d2 Compare May 26, 2026 14:03

@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: 2

🤖 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/binding/rag_analyzer.go`:
- Line 21: The cgo LDFLAGS in internal/binding/rag_analyzer.go currently
hardcodes a distro-specific library path and a versioned SONAME; update the
LDFLAGS line (the line starting with "`#cgo` linux LDFLAGS:") to remove
"-L/usr/lib/x86_64-linux-gnu" and replace "-l:libpcre2-8.so.0" with the generic
"-lpcre2-8", keeping the existing static archive and other flags
("${SRCDIR}/../cpp/cmake-build-release/librag_tokenizer_c_api.a -lstdc++ -lm
-lpthread") so the linker will use standard system search paths and an
unversioned PCRE2 symbol without introducing pkg-config.

In `@internal/service/memory.go`:
- Around line 787-789: The error from s.docEngine.UpdateChunks is being
swallowed and replaced with a generic message; change the return to preserve the
original error so callers can distinguish not-found vs server errors by wrapping
the returned err (e.g., return fmt.Errorf("failed to forget message '%d' in
memory '%s': %w", messageID, memoryID, err)) instead of discarding err when
handling the UpdateChunks call in the code that invokes
s.docEngine.UpdateChunks.
🪄 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: 525f7c5a-26d5-4f86-9356-df55b55eeabe

📥 Commits

Reviewing files that changed from the base of the PR and between 09bfc89 and 231e9d2.

📒 Files selected for processing (5)
  • internal/binding/rag_analyzer.go
  • internal/handler/memory.go
  • internal/handler/memory_message_test.go
  • internal/router/router.go
  • internal/service/memory.go

Comment thread internal/binding/rag_analyzer.go Resolved
Comment thread internal/service/memory.go Resolved

@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/memory.go (1)

580-589: ⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

Don't map arbitrary backend "not found" text to CodeNotFound.

ForgetMessage now preserves the underlying doc-engine error, so backend failures like a missing memory_{tenant} index can also match "not found" / "does not exist" here and get returned as a client 404. That hides real server-side failures. Please branch on a dedicated service error for "memory/message missing" instead of substring matching the full error text.

🤖 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/memory.go` around lines 580 - 589, The handler currently
maps any backend text containing "not found" to CodeNotFound; change it to check
for a dedicated sentinel/type error exported by the memory service (e.g.,
memory.ErrMessageNotFound or an error type returned by
h.memoryService.ForgetMessage) using errors.Is or a type assertion instead of
substring matching; only when that specific error is matched return the 404
CodeNotFound response, otherwise treat other errors as internal server errors
(log and return CodeInternal/500). Locate the call to
h.memoryService.ForgetMessage and the subsequent err handling to replace the
string checks with errors.Is(err, memory.ErrMessageNotFound) or a type switch
against the service's exported error type.
🤖 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/memory.go`:
- Around line 580-589: The handler currently maps any backend text containing
"not found" to CodeNotFound; change it to check for a dedicated sentinel/type
error exported by the memory service (e.g., memory.ErrMessageNotFound or an
error type returned by h.memoryService.ForgetMessage) using errors.Is or a type
assertion instead of substring matching; only when that specific error is
matched return the 404 CodeNotFound response, otherwise treat other errors as
internal server errors (log and return CodeInternal/500). Locate the call to
h.memoryService.ForgetMessage and the subsequent err handling to replace the
string checks with errors.Is(err, memory.ErrMessageNotFound) or a type switch
against the service's exported error type.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 593f3d0b-9fcf-46fb-b43b-95370b3e5ed4

📥 Commits

Reviewing files that changed from the base of the PR and between 231e9d2 and 714a2a8.

📒 Files selected for processing (3)
  • internal/binding/rag_analyzer.go
  • internal/handler/memory.go
  • internal/service/memory.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.

Actionable comments posted: 1

🤖 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/service/memory.go`:
- Around line 804-808: The requireMemoryAccess function currently maps any error
from s.memoryDAO.GetByID to a ResourceNotFoundError; change it to detect
gorm.ErrRecordNotFound (use errors.Is(err, gorm.ErrRecordNotFound)) and return
the 404 ResourceNotFoundError only in that case, while for any other error
propagate or wrap the original DB/infra error (e.g., return err or a new non-404
database error) so callers get a non-404 for real DB failures; update the error
handling in requireMemoryAccess (and similar branches in that function) to
follow this pattern and import "errors" and reference gorm.ErrRecordNotFound as
needed.
🪄 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: 3666ef2b-dbf7-4d80-afc9-7414db6d1088

📥 Commits

Reviewing files that changed from the base of the PR and between 714a2a8 and cd0ed8c.

📒 Files selected for processing (3)
  • internal/handler/memory.go
  • internal/handler/memory_message_test.go
  • internal/service/memory.go

Comment thread internal/service/memory.go Resolved
@Haruko386
Haruko386 self-requested a review May 27, 2026 01:43
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
@Haruko386
Haruko386 requested a review from Harry-Hz-Zhang May 28, 2026 06:33

@Harry-Hz-Zhang Harry-Hz-Zhang 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.

Hi, @jonathanchang31

The success and missing-memory responses match Python, but the existing-memory/missing-message case is not compatible.
Python returns {"code":0,"message":true} because it uses update-by-query and treats zero matched documents as success, while the Go implementation updates by id, gets no ES hit, and maps that to a 500 response.
Please make the Go path treat a missing message document the same way as Python, or intentionally document and test the changed behavior.

@coderabbitai

coderabbitai Bot commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
echo "=== internal/handler/memory.go ==="
cat internal/handler/memory.go

echo ""
echo "=== internal/handler/memory_message_test.go ==="
cat internal/handler/memory_message_test.go

echo ""
echo "=== internal/service/memory.go ==="
cat internal/service/memory.go

echo ""
echo "=== internal/router/router.go ==="
cat internal/router/router.go

echo ""
echo "=== internal/binding/rag_analyzer.go (cgo section) ==="
head -30 internal/binding/rag_analyzer.go

Length of output: 76474



@jonathanchang31 Thanks for the ping — I've read through all the changed files. Here's my review of PR #15256:


Overall Assessment

The implementation is solid and well-structured. The handler/service split is clean, error typing with ResourceNotFoundError is idiomatic Go, and the unit tests cover the important cases. A few issues worth addressing before merge:


🔴 Issues

1. Stale TODO comment in internal/service/memory.go

Near the bottom of the file there's still a leftover comment that contradicts the implementation:

// TODO: ForgetMessage - Implementation pending - depends on embedding engine
// func (s *MemoryService) ForgetMessage(memoryID string, messageID int) (bool, error) { ... }

This should be removed since ForgetMessage is now implemented.


2. isMemoryServiceNotFound doesn't check the Resource field

func isMemoryServiceNotFound(err error) bool {
    var notFoundErr *service.ResourceNotFoundError
    return errors.As(err, &notFoundErr)  // matches ANY ResourceNotFoundError
}

If other resources later use ResourceNotFoundError (e.g., Resource: "Message"), this will incorrectly return 404 instead of the appropriate error code. Consider checking the resource type:

func isMemoryServiceNotFound(err error) bool {
    var notFoundErr *service.ResourceNotFoundError
    return errors.As(err, &notFoundErr) && notFoundErr.Resource == "Memory"
}

3. requireMemoryAccess doesn't accept context.Context

func (s *MemoryService) requireMemoryAccess(userID string, memoryID string) (*entity.Memory, error) {

The DAO calls inside (GetByID, GetUserTenantRelationByUserID) can't respect request cancellation. Since ForgetMessage already receives a ctx, it should be threaded through:

func (s *MemoryService) requireMemoryAccess(ctx context.Context, userID string, memoryID string) (*entity.Memory, error) {

🟡 Minor Points

4. Silent success on missing message document

In ForgetMessage:

if isMessageDocumentNotFound(err) {
    return nil  // silently succeeds
}

This makes the delete idempotent (good), but it's worth adding a comment explaining the intent, since returning nil on "not found" during a delete is a deliberate design choice here.

5. Linux dynamic PCRE2 linking

Switching from static .a to -lpcre2-8 means libpcre2-8.so must be present at runtime on Linux deployments. This is a deployment concern — the Docker image / CI environment needs the shared library installed. If this is already handled in the container setup, worth a brief note in the PR or a README update.

6. time.Now().Local() for forget_at

now := time.Now().Local()
forgetTime := now.Format("2006-01-02 15:04:05")

Using local time can produce inconsistent values across distributed nodes with different timezone settings. Unless matching Python's behavior requires local time, time.Now().UTC() is safer.


✅ What Looks Good

  • parseMemoryMessagePath validation is thorough (empty, too many colons, non-integer, negative).
  • errors.As used correctly for typed error matching in the handler.
  • Route registration with /:memory_message correctly captures the memory_id:message_id combined param.
  • ResourceNotFoundError is a well-designed exported error type.
  • Test coverage is focused and meaningful — especially TestForgetMessageRejectsMalformedPath using a real Gin router.
  • isMessageDocumentNotFound using errors.Is with enginetypes.ErrDocumentNotFound is idiomatic.

The two highest-priority fixes before merging are #1 (stale TODO) and #2 (resource-type check in isMemoryServiceNotFound).

@Harry-Hz-Zhang Harry-Hz-Zhang 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.

@jonathanchang31, LGTM ! ! ! ! ! ! ! !

@Haruko386 Haruko386 added the ci Continue Integration label Jun 9, 2026
@Haruko386
Haruko386 marked this pull request as draft June 9, 2026 05:25
@Haruko386

Copy link
Copy Markdown
Member

@jonathanchang31 please resolve conflict, then click ready for review, and run the CI

@Haruko386
Haruko386 marked this pull request as ready for review June 9, 2026 11:07
@codecov

codecov Bot commented Jun 9, 2026 •

Copy link
Copy Markdown

Codecov Report

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

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #15256   +/-   ##
=======================================
  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 Harness.
📢 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.

@jonathanchang31

Copy link
Copy Markdown
Contributor Author

@yingfeng Could you plz review my PR? Thanks!

@Harry-Hz-Zhang Harry-Hz-Zhang 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.

@xugangqiang
xugangqiang merged commit dfcf226 into infiniflow:main Jun 10, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration 💞 feature Feature request, pull request that fullfill a new feature. size:L This PR changes 100-499 lines, ignoring generated files. 🧪 test Pull requests that update test cases.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Implement API of RAGFlow server in Go

4 participants