Skip to content

feat: implement GET /api/v1/agents/<agent_id>/versions API - #15629

Merged
yingfeng merged 5 commits into
infiniflow:mainfrom
xugangqiang:feat/go-agent-versions-api
Jun 4, 2026
Merged

yingfeng merged 5 commits into
infiniflow:mainfrom
xugangqiang:feat/go-agent-versions-api

Conversation

@xugangqiang

Copy link
Copy Markdown
Contributor

Summary

Implement the GET /api/v1/agents/<agent_id>/versions endpoint in Go, listing all version snapshots for an agent canvas in descending update time order.

Changes

  • New: internal/dao/user_canvas_version.go — UserCanvasVersionDAO with ListByCanvasID (ordered by update_time DESC) and GetByID
  • Modified: internal/service/agent.go — Added CheckCanvasAccess, ListVersions, GetVersion methods
  • Modified: internal/handler/agent.go — Added ListAgentVersions handler with auth check
  • Modified: internal/router/router.go — Registered GET /:agent_id/versions route
  • New: internal/service/agent_test.go — 5 service-level tests (SQLite in-memory DB, zero mock)
  • Modified: internal/handler/agent_test.go — 3 handler-level tests (real DB, pre-authenticated context)

Testing

All 8 tests pass with zero mocking (in-memory SQLite replaces MySQL):

=== RUN   TestListVersions_Success         --- PASS
=== RUN   TestListVersions_Empty           --- PASS
=== RUN   TestCheckCanvasAccess_Owner      --- PASS
=== RUN   TestCheckCanvasAccess_NotOwner   --- PASS
=== RUN   TestCheckCanvasAccess_NotFound   --- PASS
=== RUN   TestListAgentVersionsHandler_Success      --- PASS
=== RUN   TestListAgentVersionsHandler_NoPermission --- PASS
=== RUN   TestListAgentVersionsHandler_CanvasNotFound --- PASS

Co-Authored-By: Claude Opus 4.8 [email protected]

- Add UserCanvasVersionDAO with ListByCanvasID and GetByID
- Add CheckCanvasAccess, ListVersions, GetVersion to AgentService
- Add ListAgentVersions handler with auth check
- Register route GET /api/v1/agents/:agent_id/versions
- Add service-level tests (5 test cases, zero mock)
- Add handler-level tests (3 test cases, SQLite in-memory DB)

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@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. labels Jun 4, 2026
@coderabbitai

coderabbitai Bot commented Jun 4, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds UserCanvasVersionDAO, wires it into AgentService (CheckCanvasAccess, ListVersions, GetVersion), exposes GET /api/v1/agents/:agent_id/versions and GET /api/v1/agents/:agent_id/versions/:version_id handlers, updates router and Vite proxy, and adds unit/integration tests; removes unused test contents in two files.

Changes

Agent Version Listing

Layer / File(s) Summary
UserCanvasVersion data access
internal/dao/user_canvas_version.go
New UserCanvasVersionDAO with NewUserCanvasVersionDAO(), ListByCanvasID(canvasID) (SELECT by user_canvas_id ordered by update_time DESC), and GetByID(versionID) (SELECT by id).
AgentService canvas access control and version delegation
internal/service/agent.go
AgentService gains userCanvasVersionDAO; adds CheckCanvasAccess(userID, canvasID), ListVersions(canvasID) (delegates to DAO), and GetVersion(canvasID, versionID) (fetch and verify UserCanvasID).
HTTP handlers, router, and Vite proxy
internal/handler/agent.go, internal/router/router.go, web/vite.config.ts
AgentHandler.ListAgentVersions and GetAgentVersion added; router wires GET /api/v1/agents/:agent_id/versions and GET /api/v1/agents/:agent_id/versions/:version_id; Vite proxy regex extended for agent/version paths.
Handler integration tests (Gin + SQLite)
internal/handler/agent_test.go
Replaces fake-service tests with in-memory SQLite + GORM tests: DB setup, migrations, seeded UserCanvas/UserCanvasVersion rows, and tests for listing (order), permission denial, canvas not found, get-version success (including DSL) and not-found.
AgentService unit tests
internal/service/agent_test.go
Unit tests for ListVersions (ordering/empty), CheckCanvasAccess (owner, tenant/team, private denial, not-found), and GetVersion (success, wrong-canvas, not-found).
Test file cleanup
internal/handler/providers_test.go, internal/service/model_service_test.go
Removed prior test bodies, leaving only package declarations (test content deleted).

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • infiniflow/ragflow#15329: Modifies agent-related wiring and previously extended AgentService/AgentHandler routing for agent listing.

Suggested labels

lgtm

Suggested reviewers

  • Haruko386

Poem

🐰 I nibble code in twilight's glow,
Versions stack like carrots row on row.
DAO digs tunnels, service guards the gate,
Handlers serve them up—neat, ordered, straight.
Hop! the tests cheer: integration and fate.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive The PR description comprehensively covers the problem, changes, and testing, but does not follow the required template structure with 'What problem does this PR solve?' and 'Type of change' sections. Restructure the description to include the required template sections: 'What problem does this PR solve?' and 'Type of change' checkbox selection for clarity and consistency.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat: implement GET /api/v1/agents/<agent_id>/versions API' accurately and clearly summarizes the main change—implementing a new API endpoint for listing agent versions.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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.

✏️ 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: 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/handler/agent_test.go`:
- Around line 91-101: The test inserts two entity.UserCanvasVersion rows without
setting UpdateTime, causing nondeterministic sort order; update the fixture to
assign distinct UpdateTime values (e.g., set one to time.Now() and the other to
time.Now().Add(-time.Second) or fixed timestamps) for the records with IDs "v2"
and "v1" so the DAO's descending order by UpdateTime is deterministically
validated; apply the same change to the other fixture occurrences around the
second block (the entries referenced at lines ~128-131).

In `@internal/service/agent.go`:
- Around line 143-152: The tenant-check branch currently grants access if any
tenant ID equals canvas.UserID without verifying canvas.Permission; update the
logic in the function containing the call to
s.userTenantDAO.GetTenantIDsByUserID so it first checks canvas.Permission (the
UserCanvas permission field) and only proceeds to compare tenant IDs when
canvas.Permission indicates team-level sharing (e.g., "team"); if permission is
not team, skip the tenant loop and do not grant access even if tenant IDs match
canvas.UserID.
🪄 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: 3b789144-ff15-4f29-8cd8-2b7c88c800dd

📥 Commits

Reviewing files that changed from the base of the PR and between 597ac1e and cb78bba.

📒 Files selected for processing (6)
  • internal/dao/user_canvas_version.go
  • internal/handler/agent.go
  • internal/handler/agent_test.go
  • internal/router/router.go
  • internal/service/agent.go
  • internal/service/agent_test.go

Comment thread internal/handler/agent_test.go Resolved
Comment thread internal/service/agent.go Resolved
xugangqiang and others added 4 commits June 4, 2026 13:47
- Add Select(...) to ListByCanvasID to only return metadata fields
- Add gin.Logger() middleware for request debugging
- Register migrated agent endpoints in vite hybrid proxy config
- Fix test compilation issues

Co-Authored-By: Claude Opus 4.8 <[email protected]>
- Add Select(...) to ListByCanvasID to only return metadata fields
- Add gin.Logger() middleware for request debugging
- Register migrated agent endpoints in vite hybrid proxy config
- Fix test compilation issues

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Before this fix, any tenant member whose tenant ID matched
canvas.UserID could access the canvas, even if the canvas
had permission="me" (private).

Now the method:
- Owner always has access (unchanged)
- Non-owner: only team-level permission grants tenant access
- Non-owner + private canvas → denied even if in same tenant

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@xugangqiang xugangqiang added the ci Continue Integration label Jun 4, 2026
@xugangqiang
xugangqiang marked this pull request as draft June 4, 2026 06:01
@xugangqiang
xugangqiang marked this pull request as ready for review June 4, 2026 06:01

@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

Caution

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

⚠️ Outside diff range comments (4)
internal/service/agent_test.go (4)

242-244: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Move t.Helper() to the first line of the test function.

Same t.Helper() placement issue.

🔧 Proposed fix
 func TestCheckCanvasAccess_NotFound(t *testing.T) {
+	t.Helper()
 	testDB := setupServiceTestDB(t)
-	t.Helper()
🤖 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/agent_test.go` around lines 242 - 244, Move t.Helper() to
the top of the TestCheckCanvasAccess_NotFound test so it runs before any helper
setup; specifically, in the TestCheckCanvasAccess_NotFound function call
t.Helper() as the first statement (before calling setupServiceTestDB or any
other setup) to ensure test helpers report the correct caller location.

110-112: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Move t.Helper() to the first line of the test function.

Same issue as in TestListVersions_Success – t.Helper() should be the first statement to ensure correct stack traces on test failures.

🔧 Proposed fix
 func TestListVersions_Empty(t *testing.T) {
+	t.Helper()
 	testDB := setupServiceTestDB(t)
-	t.Helper()
🤖 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/agent_test.go` around lines 110 - 112, In
TestListVersions_Empty move the call to t.Helper() to be the first statement in
the TestListVersions_Empty function (just like in TestListVersions_Success) so
the helper is registered before any test setup; locate the
TestListVersions_Empty test function and place t.Helper() at the top of that
function body.

143-145: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Move t.Helper() to the first line of the test function.

Same t.Helper() placement issue.

🔧 Proposed fix
 func TestCheckCanvasAccess_Owner(t *testing.T) {
+	t.Helper()
 	testDB := setupServiceTestDB(t)
-	t.Helper()
🤖 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/agent_test.go` around lines 143 - 145, In
TestCheckCanvasAccess_Owner move the call to t.Helper() to the very first
statement inside the test function (before setupServiceTestDB(t) and any other
logic) so that helper reporting attributes the correct caller; update the
TestCheckCanvasAccess_Owner function accordingly to call t.Helper() as the first
line.

29-31: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Move t.Helper() to the first line of the test function.

t.Helper() is currently called after setupServiceTestDB(t), which defeats its purpose. When t.Helper() is not the first statement, test failure stack traces will incorrectly point to intermediate helper calls instead of the actual test invocation site.

🔧 Proposed fix
 func TestListVersions_Success(t *testing.T) {
+	t.Helper()
 	testDB := setupServiceTestDB(t)
-	t.Helper()
🤖 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/agent_test.go` around lines 29 - 31, Move the t.Helper()
call to the top of the TestListVersions_Success function so it runs before any
helper invocation; specifically, in TestListVersions_Success place t.Helper() as
the first statement, then call setupServiceTestDB(t), ensuring t.Helper()
executes before setupServiceTestDB to produce correct failure stack traces.
🤖 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/agent_test.go`:
- Around line 206-210: In TestCheckCanvasAccess_PrivateCanvas_Denied move the
call to t.Helper() to be the very first statement inside the test function
(immediately after func declaration) so that helper reporting is accurate;
locate the TestCheckCanvasAccess_PrivateCanvas_Denied function and reposition
t.Helper() before any setup such as setupServiceTestDB(t) or other
initialization.

---

Outside diff comments:
In `@internal/service/agent_test.go`:
- Around line 242-244: Move t.Helper() to the top of the
TestCheckCanvasAccess_NotFound test so it runs before any helper setup;
specifically, in the TestCheckCanvasAccess_NotFound function call t.Helper() as
the first statement (before calling setupServiceTestDB or any other setup) to
ensure test helpers report the correct caller location.
- Around line 110-112: In TestListVersions_Empty move the call to t.Helper() to
be the first statement in the TestListVersions_Empty function (just like in
TestListVersions_Success) so the helper is registered before any test setup;
locate the TestListVersions_Empty test function and place t.Helper() at the top
of that function body.
- Around line 143-145: In TestCheckCanvasAccess_Owner move the call to
t.Helper() to the very first statement inside the test function (before
setupServiceTestDB(t) and any other logic) so that helper reporting attributes
the correct caller; update the TestCheckCanvasAccess_Owner function accordingly
to call t.Helper() as the first line.
- Around line 29-31: Move the t.Helper() call to the top of the
TestListVersions_Success function so it runs before any helper invocation;
specifically, in TestListVersions_Success place t.Helper() as the first
statement, then call setupServiceTestDB(t), ensuring t.Helper() executes before
setupServiceTestDB to produce correct failure stack traces.
🪄 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: 32da5f3f-1665-4eff-84e9-0b29b50ad4e7

📥 Commits

Reviewing files that changed from the base of the PR and between fdf1022 and adfec07.

📒 Files selected for processing (5)
  • internal/handler/agent_test.go
  • internal/handler/providers_test.go
  • internal/service/agent.go
  • internal/service/agent_test.go
  • internal/service/model_service_test.go
💤 Files with no reviewable changes (2)
  • internal/handler/providers_test.go
  • internal/service/model_service_test.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • internal/handler/agent_test.go
  • internal/service/agent.go

Comment on lines +206 to +210
// TestCheckCanvasAccess_PrivateCanvas_Denied verifies that a tenant member
// cannot access a private (default "me") canvas.
func TestCheckCanvasAccess_PrivateCanvas_Denied(t *testing.T) {
testDB := setupServiceTestDB(t)
t.Helper()

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 | 🟡 Minor | ⚡ Quick win

Move t.Helper() to the first line of the test function.

Same t.Helper() placement issue.

🔧 Proposed fix
 func TestCheckCanvasAccess_PrivateCanvas_Denied(t *testing.T) {
+	t.Helper()
 	testDB := setupServiceTestDB(t)
-	t.Helper()
📝 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
// TestCheckCanvasAccess_PrivateCanvas_Denied verifies that a tenant member
// cannot access a private (default "me") canvas.
func TestCheckCanvasAccess_PrivateCanvas_Denied(t *testing.T) {
testDB := setupServiceTestDB(t)
t.Helper()
// TestCheckCanvasAccess_PrivateCanvas_Denied verifies that a tenant member
// cannot access a private (default "me") canvas.
func TestCheckCanvasAccess_PrivateCanvas_Denied(t *testing.T) {
t.Helper()
testDB := setupServiceTestDB(t)
🤖 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/agent_test.go` around lines 206 - 210, In
TestCheckCanvasAccess_PrivateCanvas_Denied move the call to t.Helper() to be the
very first statement inside the test function (immediately after func
declaration) so that helper reporting is accurate; locate the
TestCheckCanvasAccess_PrivateCanvas_Denied function and reposition t.Helper()
before any setup such as setupServiceTestDB(t) or other initialization.

@xugangqiang
xugangqiang force-pushed the feat/go-agent-versions-api branch from 43903b9 to adfec07 Compare June 4, 2026 06:08

@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/agent.go`:
- Around line 200-217: The handler conflates backend/service errors with
authorization/not-found responses: update the logic around
h.agentService.CheckCanvasAccess(user.ID, agentID) and
h.agentService.GetVersion(agentID, versionID) to first check for non-nil err and
respond with common.CodeServerError (with a server-error message), and only if
err==nil map the boolean result (ok==false) to common.CodeOperatingError and a
clear "no permission/agent not found" message; similarly, after calling
GetVersion, if err!=nil return common.CodeServerError, and only if err==nil but
version is nil or missing return common.CodeNotFound — use the existing symbols
CheckCanvasAccess and GetVersion and preserve the current JSON shape.
🪄 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: 42fc8583-9b5d-4a6e-b330-e1f30fc48101

📥 Commits

Reviewing files that changed from the base of the PR and between adfec07 and 43903b9.

📒 Files selected for processing (5)
  • internal/handler/agent.go
  • internal/handler/agent_test.go
  • internal/router/router.go
  • internal/service/agent_test.go
  • web/vite.config.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • internal/router/router.go
  • web/vite.config.ts

Comment thread internal/handler/agent.go Outdated
Comment on lines +200 to +217
ok, err := h.agentService.CheckCanvasAccess(user.ID, agentID)
if err != nil || !ok {
c.JSON(http.StatusOK, gin.H{
"code": common.CodeOperatingError,
"data": nil,
"message": "Agent not found or no permission.",
})
return
}

version, err := h.agentService.GetVersion(agentID, versionID)
if err != nil {
c.JSON(http.StatusOK, gin.H{
"code": common.CodeNotFound,
"data": nil,
"message": "Version not found.",
})
return

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

Separate access/version misses from backend failures.

CheckCanvasAccess and GetVersion both propagate DAO errors, but this handler collapses every err != nil case into "Agent not found or no permission." or "Version not found.". A transient DB failure will therefore look like an authorization/not-found response to clients. Handle service errors first with CodeServerError, and only map the explicit deny/missing-version cases to CodeOperatingError / CodeNotFound.

Suggested direction
 	ok, err := h.agentService.CheckCanvasAccess(user.ID, agentID)
-	if err != nil || !ok {
+	if err != nil {
+		c.JSON(http.StatusOK, gin.H{
+			"code":    common.CodeServerError,
+			"data":    nil,
+			"message": err.Error(),
+		})
+		return
+	}
+	if !ok {
 		c.JSON(http.StatusOK, gin.H{
 			"code":    common.CodeOperatingError,
 			"data":    nil,
 			"message": "Agent not found or no permission.",
 		})
 		return
 	}

 	version, err := h.agentService.GetVersion(agentID, versionID)
 	if err != nil {
-		c.JSON(http.StatusOK, gin.H{
-			"code":    common.CodeNotFound,
-			"data":    nil,
-			"message": "Version not found.",
-		})
+		// Prefer a sentinel from the service layer, e.g. service.ErrVersionNotFound.
+		c.JSON(http.StatusOK, gin.H{
+			"code":    common.CodeServerError,
+			"data":    nil,
+			"message": err.Error(),
+		})
 		return
 	}
📝 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
ok, err := h.agentService.CheckCanvasAccess(user.ID, agentID)
if err != nil || !ok {
c.JSON(http.StatusOK, gin.H{
"code": common.CodeOperatingError,
"data": nil,
"message": "Agent not found or no permission.",
})
return
}
version, err := h.agentService.GetVersion(agentID, versionID)
if err != nil {
c.JSON(http.StatusOK, gin.H{
"code": common.CodeNotFound,
"data": nil,
"message": "Version not found.",
})
return
ok, err := h.agentService.CheckCanvasAccess(user.ID, agentID)
if err != nil {
c.JSON(http.StatusOK, gin.H{
"code": common.CodeServerError,
"data": nil,
"message": err.Error(),
})
return
}
if !ok {
c.JSON(http.StatusOK, gin.H{
"code": common.CodeOperatingError,
"data": nil,
"message": "Agent not found or no permission.",
})
return
}
version, err := h.agentService.GetVersion(agentID, versionID)
if err != nil {
// Prefer a sentinel from the service layer, e.g. service.ErrVersionNotFound.
c.JSON(http.StatusOK, gin.H{
"code": common.CodeServerError,
"data": nil,
"message": err.Error(),
})
return
}
🤖 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/agent.go` around lines 200 - 217, The handler conflates
backend/service errors with authorization/not-found responses: update the logic
around h.agentService.CheckCanvasAccess(user.ID, agentID) and
h.agentService.GetVersion(agentID, versionID) to first check for non-nil err and
respond with common.CodeServerError (with a server-error message), and only if
err==nil map the boolean result (ok==false) to common.CodeOperatingError and a
clear "no permission/agent not found" message; similarly, after calling
GetVersion, if err!=nil return common.CodeServerError, and only if err==nil but
version is nil or missing return common.CodeNotFound — use the existing symbols
CheckCanvasAccess and GetVersion and preserve the current JSON shape.

@codecov

codecov Bot commented Jun 4, 2026

Copy link
Copy Markdown

Codecov Report

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

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

@yingfeng
yingfeng merged commit 02d163a into infiniflow:main Jun 4, 2026
2 of 3 checks passed
yingfeng pushed a commit that referenced this pull request Jun 4, 2026
…PI (#15640)

## Summary

Implement the `GET /api/v1/agents/<agent_id>/versions/<version_id>`
endpoint in Go, returning full version details including DSL.

Depends on #15629 which introduced the version list endpoint and
`UserCanvasVersionDAO` infrastructure.

### Changes

- **Modified**: `internal/handler/agent.go` — Added `GetAgentVersion`
handler with auth check and ownership verification
- **Modified**: `internal/router/router.go` — Registered `GET
/:agent_id/versions/:version_id` route
- **New/Modified tests**: Service and handler tests for the version
detail endpoint

### Testing

```
=== RUN   TestGetVersion_Success       --- PASS
=== RUN   TestGetVersion_WrongCanvas   --- PASS
=== RUN   TestGetVersion_NotFound      --- PASS
=== RUN   TestGetAgentVersionHandler_Success      --- PASS
=== RUN   TestGetAgentVersionHandler_VersionNotFound --- PASS
```

Co-Authored-By: Claude Opus 4.8 <[email protected]>

---------

Co-authored-by: Claude Opus 4.8 <[email protected]>
@xugangqiang
xugangqiang deleted the feat/go-agent-versions-api branch August 7, 2026 12:44
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants