Skip to content

Fix: better GetByID - #20421

Merged
wangq8 merged 1 commit into
infiniflow:mainfrom
Lynn-Inf:refactor/get-by-id
Sep 30, 2026
Merged

wangq8 merged 1 commit into
infiniflow:mainfrom
Lynn-Inf:refactor/get-by-id

Conversation

@Lynn-Inf

Copy link
Copy Markdown
Contributor

Summary

As title.

@Lynn-Inf
Lynn-Inf requested a review from wangq8 September 30, 2026 02:31
@Lynn-Inf Lynn-Inf added the ci Continue Integration label Sep 30, 2026
@coderabbitai

coderabbitai Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 6690f4a4-bc12-4224-84aa-bd3dfd6d8caa

📥 Commits

Reviewing files that changed from the base of the PR and between fc578ea and 90b3960.

📒 Files selected for processing (20)
  • AGENTS.md
  • internal/dao/api_for_conversation.go
  • internal/dao/chat.go
  • internal/dao/chat_channel.go
  • internal/dao/chat_session.go
  • internal/dao/compilation_template.go
  • internal/dao/connector.go
  • internal/dao/document.go
  • internal/dao/file_commit.go
  • internal/dao/ingestion.go
  • internal/dao/mcp.go
  • internal/dao/memory.go
  • internal/dao/pipeline_operation_log.go
  • internal/dao/task.go
  • internal/dao/tenant_model.go
  • internal/dao/tenant_model_group.go
  • internal/dao/tenant_model_instance.go
  • internal/dao/tenant_model_provider.go
  • internal/dao/user.go
  • internal/dao/user_canvas.go

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

DAO ID lookups now use GORM Take instead of First or Find in multiple methods. The conversation lookup maps gorm.ErrRecordNotFound to (nil, nil). AGENTS.md adds guidance on binding string IDs and checking generated SQL with DryRun.

Changes

DAO ID lookups

Layer / File(s) Summary
Switch DAO ID lookups to Take
internal/dao/..., AGENTS.md
Multiple DAO methods use Take for ID lookups. Most retain their ID filters and error handling. The conversation lookup returns (nil, nil) for gorm.ErrRecordNotFound. AGENTS.md advises explicit ID binding and checking generated SQL with DryRun when changing query forms.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: jinhai-cn

Merge Risk: ⚪ Minimal · up to 90b39

The DAO lookups continue to retrieve records by ID and preserve missing-record behavior; no material user-facing regression is evident.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 90b39

The updated lookups explicitly bind IDs and generally preserve existing error handling and authorization responsibilities. No new security failure was established. A pre-existing numeric-to-string user-ID mismatch leaves some uncertainty about account selection after ordering is removed.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — For the string-ID lookups, attacker-supplied IDs remain database values rather than executable SQL conditions. With enforced primary-key equality, the changed query remains confined to the identified record; access to that record still depends on existing caller controls.

Security Findings and Attack Paths

  • inferred — The user handler parses a request ID as uint, and the service returns fields from the DAO-selected account. The uint argument against a string primary key predates this PR. Removing ordering could affect which account is returned if database coercion permits multiple matches, but deployed comparison behavior and public route exposure are unresolved; an introduced attack path is not established.

Trust Boundaries and Controls

  • observed — The inspected memory authorization path still checks ownership, permission mode and team membership after retrieving the requested memory. The lookup change retains its bound ID condition and does not remove those checks.

Hardening Proposals

  • proposed — Align the user lookup argument with the model's string identity type and validate comparison behavior on supported database dialects. This would remove the pre-existing coercion ambiguity rather than remedy a verified vulnerability introduced here.
🚥 Pre-merge checks | ✅ 3 | ❌ 1 | ❓ 1

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description includes the required Summary heading but provides no purpose, background, or explanation beyond “As title.” It does not give reviewers enough context about the GORM query changes. Add a brief summary that explains the GetByID query changes, the GORM behavior being corrected, and why explicit ID conditions with Take are required.
Title check ❓ Inconclusive The title identifies the affected GetByID methods but does not state the actual change, such as replacing First with Take and using explicit ID conditions. The word “better” is vague. Replace the title with a specific summary, such as “Fix GetByID queries by using Take with explicit ID filters.”
✅ Passed checks (3 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
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.
  • Fix all pre-merge checks with AI

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

A rabbit checks each query’s trail
With Take, the ID finds its way
Bind the string and check the SQL
DryRun shows the clause at play
Then hops along, content and well

Comment @coderabbitai help to get the list of available commands.

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

Labels

ci Continue Integration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants