Skip to content

fix: get team's search in own search-list - #16599

Merged
JinHai-CN merged 2 commits into
infiniflow:mainfrom
Haruko386:master
Jul 3, 2026
Merged

JinHai-CN merged 2 commits into
infiniflow:mainfrom
Haruko386:master

Conversation

@Haruko386

@Haruko386 Haruko386 commented Jul 3, 2026 •

Copy link
Copy Markdown
Member

Summary

As title:
bug:
image

fixed:
image

@Haruko386 Haruko386 added 🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration labels Jul 3, 2026
@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Jul 3, 2026
@coderabbitai

coderabbitai Bot commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 700ef63d-e594-4ef5-9ca0-e8acdcd87a78

📥 Commits

Reviewing files that changed from the base of the PR and between a824a6a and fef9252.

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

📝 Walkthrough

Walkthrough

This PR adds owner_ids query-parameter support to ListSearches, filters requested owner IDs against accessible tenants in the service, and changes tenant-based DAO filtering to branch on whether tenant IDs are provided.

Changes

Owner ID search filtering

Layer / File(s) Summary
DAO conditional tenant filtering
internal/dao/search.go
ListByTenantIDs now applies search.tenant_id = userID when tenantIDs is empty, or (tenant_id IN ? OR tenant_id = ?) when non-empty, both with status = "1".
Service owner ID access filtering
internal/service/search.go
ListSearches skips the tenant-ID pre-fetch for empty owner IDs and filters provided owner IDs through filterAccessibleSearchOwnerIDs before querying.
Handler query parsing and wiring
internal/handler/search.go
Adds getSearchOwnerIDs for query parsing, updates GET route docs, and uses a JSON body fallback only when query parsing yields no owner IDs.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant Handler
  participant SearchService
  participant SearchDAO

  Client->>Handler: GET /searches?owner_ids=...
  Handler->>Handler: getSearchOwnerIDs(c)
  alt ownerIDs empty and body present
    Handler->>Handler: parse JSON body for owner_ids
  end
  Handler->>SearchService: ListSearches(ownerIDs, ...)
  alt ownerIDs empty
    SearchService->>SearchDAO: ListByTenantIDs(nil, userID, ...)
  else ownerIDs provided
    SearchService->>SearchService: filterAccessibleSearchOwnerIDs(userID, ownerIDs)
    SearchService->>SearchDAO: ListByOwnerIDs(filteredOwnerIDs, ...)
  end
  SearchDAO-->>SearchService: results
  SearchService-->>Handler: results
  Handler-->>Client: response
Loading

Poem

A rabbit hopped through query strings,
Found owner_ids on comma-wings,
Tenants checked, then paths align,
Search results hop in tidy line.
🐰✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main fix: making team searches appear in the team's own search list.
Description check ✅ Passed The description includes a brief summary and before/after screenshots, matching the required Summary section.
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.

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.

@Haruko386
Haruko386 marked this pull request as draft July 3, 2026 06:59
@Haruko386
Haruko386 marked this pull request as ready for review July 3, 2026 06:59

@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

🧹 Nitpick comments (1)
internal/dao/search.go (1)

59-65: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Drop the unused tenantIDs branch
internal/service/search.go only calls SearchDAO.ListByTenantIDs(nil, ...), so the len(tenantIDs) > 0 path here is currently unreachable. Remove the dead branch or wire in a caller that passes real tenant IDs.

🤖 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/dao/search.go` around lines 59 - 65, The `ListByTenantIDs` query in
`search.go` has an unreachable `len(tenantIDs) > 0` branch because
`SearchDAO.ListByTenantIDs` is only called with nil from
`internal/service/search.go`. Remove the dead `tenantIDs` condition from
`ListByTenantIDs`, or update the caller/service flow to pass real tenant IDs if
that path is intended, while keeping the existing `query.Where` logic and
`userID`/status filtering consistent.
🤖 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/search.go`:
- Around line 117-134: Restricting owner_ids is missing before the search query,
so a caller can pass arbitrary tenant IDs into search handling. Update the
search handler logic around getSearchOwnerIDs and the ListSearches call to
intersect the requested ownerIDs with the authenticated user’s tenant
memberships before invoking h.searchService.ListSearches, and reject or drop any
IDs the caller does not belong to. Keep the existing GET-body fallback for
compatibility, but ensure the final ownerIDs passed to ListSearches are
caller-validated only.

---

Nitpick comments:
In `@internal/dao/search.go`:
- Around line 59-65: The `ListByTenantIDs` query in `search.go` has an
unreachable `len(tenantIDs) > 0` branch because `SearchDAO.ListByTenantIDs` is
only called with nil from `internal/service/search.go`. Remove the dead
`tenantIDs` condition from `ListByTenantIDs`, or update the caller/service flow
to pass real tenant IDs if that path is intended, while keeping the existing
`query.Where` logic and `userID`/status filtering consistent.
🪄 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: 7cd4d038-289f-4fed-9155-ff7c764bc6c7

📥 Commits

Reviewing files that changed from the base of the PR and between 994b603 and a824a6a.

📒 Files selected for processing (3)
  • internal/dao/search.go
  • internal/handler/search.go
  • internal/service/search.go

Comment thread internal/handler/search.go Resolved
@JinHai-CN
JinHai-CN merged commit dde8b6d into infiniflow:main Jul 3, 2026
3 checks passed
xugangqiang pushed a commit to xugangqiang/ragflow that referenced this pull request Jul 3, 2026
xugangqiang pushed a commit to xugangqiang/ragflow that referenced this pull request Jul 6, 2026
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:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants