Skip to content

fix(agent): bind session_id to path agent_id on GET/DELETE agent sessions - #15374

Merged
yuzhichang merged 2 commits into
infiniflow:mainfrom
pekar9781:fix/agent-session-idor
Jun 28, 2026
Merged

yuzhichang merged 2 commits into
infiniflow:mainfrom
pekar9781:fix/agent-session-idor

Conversation

@pekar9781

Copy link
Copy Markdown

Related issues

Closes #15128

What problem does this PR solve?

GET and DELETE /api/v1/agents/<agent_id>/sessions/<session_id> verified canvas access for agent_id in the URL but loaded/deleted sessions only by session_id, without checking conv.dialog_id == agent_id.

Any user with access to any agent could read or delete another agent's API4Conversation session (messages, references, DSL, etc.) when they knew the session UUID.

Agent completions in the same file already enforce this binding; chat sessions do too — these two routes were inconsistent.

Type of change

  • Bug Fix (non-breaking change which fixes an issue)
  • New Feature (non-breaking change which adds functionality)
  • Documentation Update
  • Refactoring
  • Performance Improvement
  • Other (please describe):

Changes

File Change
api/apps/restful_apis/agent_api.py Require conv.dialog_id == agent_id in get_agent_session and delete_agent_session_item; return generic "Session not found!" on mismatch
test/unit_test/api/apps/restful_apis/test_get_agent_session.py Add IDOR regression tests for GET/DELETE; fix success fixture to include dialog_id; track delete_by_id calls

Test plan

  • Unit tests added for GET/DELETE IDOR and success paths
  • pytest test/unit_test/api/apps/restful_apis/test_get_agent_session.py

@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 May 28, 2026
@coderabbitai

coderabbitai Bot commented May 28, 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: cb649d73-cca9-47d9-8f45-8cc0d14c2539

📥 Commits

Reviewing files that changed from the base of the PR and between 19c9165 and d90ffb5.

📒 Files selected for processing (1)
  • api/apps/restful_apis/agent_api.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • api/apps/restful_apis/agent_api.py

📝 Walkthrough

Walkthrough

This PR hardens agent session GET and DELETE endpoints by verifying session ownership through dialog_id before returning or deleting a session. The tests add regression coverage for mismatched-agent requests and confirm delete tracking.

Changes

Agent Session IDOR Fix

Layer / File(s) Summary
GET/DELETE endpoint IDOR validation
api/apps/restful_apis/agent_api.py
get_agent_session and delete_agent_session_item now validate that the loaded session's dialog_id matches the requested agent_id; mismatches return "Session not found!".
Test helper and IDOR regression coverage
test/unit_test/api/apps/restful_apis/test_get_agent_session.py
The test helper now records delete calls; existing GET tests adapt to the new return shape; new tests cover rejected cross-agent GET/DELETE requests and successful owned-session deletion.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 I hopped through sessions, far and near,
But ownership checks are crystal clear.
If dialog_id don’t match the key,
The bunny says: “Not found!” politely.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and accurately summarizes the main GET/DELETE agent-session binding fix.
Description check ✅ Passed The description includes the required problem statement and type-of-change section, with useful context, changes, and test plan.
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.

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

🧹 Nitpick comments (1)
api/apps/restful_apis/agent_api.py (1)

440-444: 💤 Low value

DELETE ownership check is correct. Validating conv.dialog_id != agent_id before delete_by_id prevents cross-agent deletion, consistent with the GET path.

Optionally, consider emitting a logging.warning on the rejection branch (covers both GET and DELETE) to surface attempted IDOR access for security monitoring. As per coding guidelines, "Add logging for new flows".

🤖 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 `@api/apps/restful_apis/agent_api.py` around lines 440 - 444, In
delete_agent_session_item, add a logging warning when the ownership check fails:
after calling API4ConversationService.get_by_id(session_id) and before returning
get_data_error_result, call logging.warning with context including agent_id,
session_id and tenant_id to record the refused DELETE (the same pattern should
be applied to the GET path if present); keep the existing check on
conv.dialog_id != agent_id and do not change the delete call to
API4ConversationService.delete_by_id(session_id).
🤖 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 `@api/apps/restful_apis/agent_api.py`:
- Around line 440-444: In delete_agent_session_item, add a logging warning when
the ownership check fails: after calling
API4ConversationService.get_by_id(session_id) and before returning
get_data_error_result, call logging.warning with context including agent_id,
session_id and tenant_id to record the refused DELETE (the same pattern should
be applied to the GET path if present); keep the existing check on
conv.dialog_id != agent_id and do not change the delete call to
API4ConversationService.delete_by_id(session_id).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d7c86e8c-87a9-4a82-901b-2632404f029b

📥 Commits

Reviewing files that changed from the base of the PR and between 7fc909a and 19c9165.

📒 Files selected for processing (2)
  • api/apps/restful_apis/agent_api.py
  • test/unit_test/api/apps/restful_apis/test_get_agent_session.py

@yuzhichang
yuzhichang self-requested a review June 28, 2026 00:49
@yuzhichang
yuzhichang merged commit 74c2944 into infiniflow:main Jun 28, 2026
3 checks passed
yuzhichang added a commit that referenced this pull request Jun 29, 2026
…ions (#15374)

## Related issues

Closes #15128

### What problem does this PR solve?

`GET` and `DELETE` `/api/v1/agents/<agent_id>/sessions/<session_id>`
verified canvas access for `agent_id` in the URL but loaded/deleted
sessions only by `session_id`, without checking `conv.dialog_id ==
agent_id`.

Any user with access to **any** agent could read or delete another
agent's `API4Conversation` session (messages, references, DSL, etc.)
when they knew the session UUID.

Agent completions in the same file already enforce this binding; chat
sessions do too — these two routes were inconsistent.

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
- [ ] New Feature (non-breaking change which adds functionality)
- [ ] Documentation Update
- [ ] Refactoring
- [ ] Performance Improvement
- [ ] Other (please describe):

### Changes

| File | Change |
|------|--------|
| `api/apps/restful_apis/agent_api.py` | Require `conv.dialog_id ==
agent_id` in `get_agent_session` and `delete_agent_session_item`; return
generic `"Session not found!"` on mismatch |
| `test/unit_test/api/apps/restful_apis/test_get_agent_session.py` | Add
IDOR regression tests for GET/DELETE; fix success fixture to include
`dialog_id`; track `delete_by_id` calls |

### Test plan

- [x] Unit tests added for GET/DELETE IDOR and success paths
- [ ] `pytest
test/unit_test/api/apps/restful_apis/test_get_agent_session.py`

Co-authored-by: Cursor <[email protected]>
Co-authored-by: Zhichang Yu <[email protected]>
yuzhichang added a commit to yuzhichang/ragflow that referenced this pull request Jun 29, 2026
Ports 5 S-effort PRs from .claude/plans/review-and-port-py-agent-changes.md
Execution snapshot (all merged upstream) to the Go agent side.

Group 1 - tool ports
- infiniflow#15609 ExeSQL SSRF guard: add ValidateDBHost to tool/ssrf.go and
  wire into exesql.InvokableRun. Loopback, link-local, RFC1918, and
  empty host are rejected before any driver dispatch. Allowed hosts
  are dialed via the validated/resolved public IP (DNS-pin).
- infiniflow#15436 HTTP timeout: Go side already routes github/qweather/tushare
  through HTTPHelper (client.Timeout: 30s + per-stage timeouts) and
  jin10 is a stub. Added regression guard tests: default client
  timeout, stage timeouts, and AST scan for bare http.Get/Post calls
  outside the helper.

Group 2 - component ports
- infiniflow#16363 be_output restore + DeepL error: add BeOutput(v) helper
  returning {"content": v} frame; add DeepL translation-failure
  regression test using rewriteHostTransport (avoids mutating
  package globals which raced TestDeepL_BuildRequest).
- infiniflow#15644 Switch no longer matches empty condition: evaluateGroup
  empty-clauses short-circuit now returns false (was true) so an
  "and" condition with no clauses falls through to the next
  condition or end_cpn_ids instead of routing to the empty
  group's "to" target. Mirrors the all([]) is True fix.

Group 4 - API ports
- infiniflow#15374 session_id bind to path agent_id: Go DAO already enforces
  WHERE id = ? AND dialog_id = ? (stronger than the Python
  post-fetch check). Added 3 IDOR regression tests at the service
  level (Get/Get mismatch/Delete) confirming the binding holds.

Total: 32 new tests across 4 new test files. All agent/tool and
agent/component tests pass (320 + 331). All new service IDOR
tests pass (3/3). The one failing test in agent/component
(TestAgent_ReActExhaustsSteps) is a pre-existing flaky test that
also fails on the baseline without my changes.

Refs: .claude/plans/review-and-port-py-agent-changes.md
Refs: infiniflow#15609 infiniflow#15436 infiniflow#16363 infiniflow#15644 infiniflow#15374
yuzhichang added a commit to yuzhichang/ragflow that referenced this pull request Jun 29, 2026
Ports 5 S-effort PRs from .claude/plans/review-and-port-py-agent-changes.md
Execution snapshot (all merged upstream) to the Go agent side.

Group 1 - tool ports
- infiniflow#15609 ExeSQL SSRF guard: add ValidateDBHost to tool/ssrf.go and
  wire into exesql.InvokableRun. Loopback, link-local, RFC1918, and
  empty host are rejected before any driver dispatch. Allowed hosts
  are dialed via the validated/resolved public IP (DNS-pin).
- infiniflow#15436 HTTP timeout: Go side already routes github/qweather/tushare
  through HTTPHelper (client.Timeout: 30s + per-stage timeouts) and
  jin10 is a stub. Added regression guard tests: default client
  timeout, stage timeouts, and AST scan for bare http.Get/Post calls
  outside the helper.

Group 2 - component ports
- infiniflow#16363 be_output restore + DeepL error: add BeOutput(v) helper
  returning {"content": v} frame; add DeepL translation-failure
  regression test using rewriteHostTransport (avoids mutating
  package globals which raced TestDeepL_BuildRequest).
- infiniflow#15644 Switch no longer matches empty condition: evaluateGroup
  empty-clauses short-circuit now returns false (was true) so an
  "and" condition with no clauses falls through to the next
  condition or end_cpn_ids instead of routing to the empty
  group's "to" target. Mirrors the all([]) is True fix.

Group 4 - API ports
- infiniflow#15374 session_id bind to path agent_id: Go DAO already enforces
  WHERE id = ? AND dialog_id = ? (stronger than the Python
  post-fetch check). Added 3 IDOR regression tests at the service
  level (Get/Get mismatch/Delete) confirming the binding holds.

Total: 32 new tests across 4 new test files. All agent/tool and
agent/component tests pass (320 + 331). All new service IDOR
tests pass (3/3). The one failing test in agent/component
(TestAgent_ReActExhaustsSteps) is a pre-existing flaky test that
also fails on the baseline without my changes.

Refs: .claude/plans/review-and-port-py-agent-changes.md
Refs: infiniflow#15609 infiniflow#15436 infiniflow#16363 infiniflow#15644 infiniflow#15374
yuzhichang added a commit to yuzhichang/ragflow that referenced this pull request Jun 29, 2026
Ports 5 S-effort PRs from .claude/plans/review-and-port-py-agent-changes.md
Execution snapshot (all merged upstream) to the Go agent side.

Group 1 - tool ports
- infiniflow#15609 ExeSQL SSRF guard: add ValidateDBHost to tool/ssrf.go and
  wire into exesql.InvokableRun. Loopback, link-local, RFC1918, and
  empty host are rejected before any driver dispatch. Allowed hosts
  are dialed via the validated/resolved public IP (DNS-pin).
- infiniflow#15436 HTTP timeout: Go side already routes github/qweather/tushare
  through HTTPHelper (client.Timeout: 30s + per-stage timeouts) and
  jin10 is a stub. Added regression guard tests: default client
  timeout, stage timeouts, and AST scan for bare http.Get/Post calls
  outside the helper.

Group 2 - component ports
- infiniflow#16363 be_output restore + DeepL error: add BeOutput(v) helper
  returning {"content": v} frame; add DeepL translation-failure
  regression test using rewriteHostTransport (avoids mutating
  package globals which raced TestDeepL_BuildRequest).
- infiniflow#15644 Switch no longer matches empty condition: evaluateGroup
  empty-clauses short-circuit now returns false (was true) so an
  "and" condition with no clauses falls through to the next
  condition or end_cpn_ids instead of routing to the empty
  group's "to" target. Mirrors the all([]) is True fix.

Group 4 - API ports
- infiniflow#15374 session_id bind to path agent_id: Go DAO already enforces
  WHERE id = ? AND dialog_id = ? (stronger than the Python
  post-fetch check). Added 3 IDOR regression tests at the service
  level (Get/Get mismatch/Delete) confirming the binding holds.

Total: 32 new tests across 4 new test files. All agent/tool and
agent/component tests pass (320 + 331). All new service IDOR
tests pass (3/3). The one failing test in agent/component
(TestAgent_ReActExhaustsSteps) is a pre-existing flaky test that
also fails on the baseline without my changes.

Refs: .claude/plans/review-and-port-py-agent-changes.md
Refs: infiniflow#15609 infiniflow#15436 infiniflow#16363 infiniflow#15644 infiniflow#15374
yuzhichang added a commit to yuzhichang/ragflow that referenced this pull request Jun 29, 2026
Ports 5 S-effort PRs from .claude/plans/review-and-port-py-agent-changes.md
Execution snapshot (all merged upstream) to the Go agent side.

Group 1 - tool ports
- infiniflow#15609 ExeSQL SSRF guard: add ValidateDBHost to tool/ssrf.go and
  wire into exesql.InvokableRun. Loopback, link-local, RFC1918, and
  empty host are rejected before any driver dispatch. Allowed hosts
  are dialed via the validated/resolved public IP (DNS-pin).
- infiniflow#15436 HTTP timeout: Go side already routes github/qweather/tushare
  through HTTPHelper (client.Timeout: 30s + per-stage timeouts) and
  jin10 is a stub. Added regression guard tests: default client
  timeout, stage timeouts, and AST scan for bare http.Get/Post calls
  outside the helper.

Group 2 - component ports
- infiniflow#16363 be_output restore + DeepL error: add BeOutput(v) helper
  returning {"content": v} frame; add DeepL translation-failure
  regression test using rewriteHostTransport (avoids mutating
  package globals which raced TestDeepL_BuildRequest).
- infiniflow#15644 Switch no longer matches empty condition: evaluateGroup
  empty-clauses short-circuit now returns false (was true) so an
  "and" condition with no clauses falls through to the next
  condition or end_cpn_ids instead of routing to the empty
  group's "to" target. Mirrors the all([]) is True fix.

Group 4 - API ports
- infiniflow#15374 session_id bind to path agent_id: Go DAO already enforces
  WHERE id = ? AND dialog_id = ? (stronger than the Python
  post-fetch check). Added 3 IDOR regression tests at the service
  level (Get/Get mismatch/Delete) confirming the binding holds.

Total: 32 new tests across 4 new test files. All agent/tool and
agent/component tests pass (320 + 331). All new service IDOR
tests pass (3/3). The one failing test in agent/component
(TestAgent_ReActExhaustsSteps) is a pre-existing flaky test that
also fails on the baseline without my changes.

Refs: .claude/plans/review-and-port-py-agent-changes.md
Refs: infiniflow#15609 infiniflow#15436 infiniflow#16363 infiniflow#15644 infiniflow#15374
yuzhichang added a commit to yuzhichang/ragflow that referenced this pull request Jun 29, 2026
Ports 5 S-effort PRs from .claude/plans/review-and-port-py-agent-changes.md
Execution snapshot (all merged upstream) to the Go agent side.

Group 1 - tool ports
- infiniflow#15609 ExeSQL SSRF guard: add ValidateDBHost to tool/ssrf.go and
  wire into exesql.InvokableRun. Loopback, link-local, RFC1918, and
  empty host are rejected before any driver dispatch. Allowed hosts
  are dialed via the validated/resolved public IP (DNS-pin).
- infiniflow#15436 HTTP timeout: Go side already routes github/qweather/tushare
  through HTTPHelper (client.Timeout: 30s + per-stage timeouts) and
  jin10 is a stub. Added regression guard tests: default client
  timeout, stage timeouts, and AST scan for bare http.Get/Post calls
  outside the helper.

Group 2 - component ports
- infiniflow#16363 be_output restore + DeepL error: add BeOutput(v) helper
  returning {"content": v} frame; add DeepL translation-failure
  regression test using rewriteHostTransport (avoids mutating
  package globals which raced TestDeepL_BuildRequest).
- infiniflow#15644 Switch no longer matches empty condition: evaluateGroup
  empty-clauses short-circuit now returns false (was true) so an
  "and" condition with no clauses falls through to the next
  condition or end_cpn_ids instead of routing to the empty
  group's "to" target. Mirrors the all([]) is True fix.

Group 4 - API ports
- infiniflow#15374 session_id bind to path agent_id: Go DAO already enforces
  WHERE id = ? AND dialog_id = ? (stronger than the Python
  post-fetch check). Added 3 IDOR regression tests at the service
  level (Get/Get mismatch/Delete) confirming the binding holds.

Total: 32 new tests across 4 new test files. All agent/tool and
agent/component tests pass (320 + 331). All new service IDOR
tests pass (3/3). The one failing test in agent/component
(TestAgent_ReActExhaustsSteps) is a pre-existing flaky test that
also fails on the baseline without my changes.

Refs: .claude/plans/review-and-port-py-agent-changes.md
Refs: infiniflow#15609 infiniflow#15436 infiniflow#16363 infiniflow#15644 infiniflow#15374
yuzhichang added a commit to yuzhichang/ragflow that referenced this pull request Jun 30, 2026
Ports 5 S-effort PRs from .claude/plans/review-and-port-py-agent-changes.md
Execution snapshot (all merged upstream) to the Go agent side.

Group 1 - tool ports
- infiniflow#15609 ExeSQL SSRF guard: add ValidateDBHost to tool/ssrf.go and
  wire into exesql.InvokableRun. Loopback, link-local, RFC1918, and
  empty host are rejected before any driver dispatch. Allowed hosts
  are dialed via the validated/resolved public IP (DNS-pin).
- infiniflow#15436 HTTP timeout: Go side already routes github/qweather/tushare
  through HTTPHelper (client.Timeout: 30s + per-stage timeouts) and
  jin10 is a stub. Added regression guard tests: default client
  timeout, stage timeouts, and AST scan for bare http.Get/Post calls
  outside the helper.

Group 2 - component ports
- infiniflow#16363 be_output restore + DeepL error: add BeOutput(v) helper
  returning {"content": v} frame; add DeepL translation-failure
  regression test using rewriteHostTransport (avoids mutating
  package globals which raced TestDeepL_BuildRequest).
- infiniflow#15644 Switch no longer matches empty condition: evaluateGroup
  empty-clauses short-circuit now returns false (was true) so an
  "and" condition with no clauses falls through to the next
  condition or end_cpn_ids instead of routing to the empty
  group's "to" target. Mirrors the all([]) is True fix.

Group 4 - API ports
- infiniflow#15374 session_id bind to path agent_id: Go DAO already enforces
  WHERE id = ? AND dialog_id = ? (stronger than the Python
  post-fetch check). Added 3 IDOR regression tests at the service
  level (Get/Get mismatch/Delete) confirming the binding holds.

Total: 32 new tests across 4 new test files. All agent/tool and
agent/component tests pass (320 + 331). All new service IDOR
tests pass (3/3). The one failing test in agent/component
(TestAgent_ReActExhaustsSteps) is a pre-existing flaky test that
also fails on the baseline without my changes.

Refs: .claude/plans/review-and-port-py-agent-changes.md
Refs: infiniflow#15609 infiniflow#15436 infiniflow#16363 infiniflow#15644 infiniflow#15374

Apply unstaged agent-go-port prep work

docker/.env
  - switch API_PROXY_SCHEME from python to go (Go server is the default)
  - enable SANDBOX_ENABLED=1 and extend COMPOSE_PROFILES with ragflow-go

web/CLAUDE.md
  - document frontend agent conventions: CSS/flex layout debugging,
    scope boundaries, i18n language files, query-key factory pattern,
    request layering (hook -> service -> next-request), shared UI lock,
    utility libs (dayjs, ahooks, lodash)

web/.agents/skills/tanstack-query-best-practices/
  - remove the full tanstack-query-best-practices skill set
    (SKILL.md + 21 rule files, 1,535 lines total)

Lefthook pre-commit was satisfied after stripping two pre-existing
trailing-whitespace lines from docker/.env comments.

chore(hooks): enable auto-fix for staged file checks

Convert lefthook pre-commit to B-mode (check + auto-fix in place)
for the four fixable jobs:

- end-of-file-fixer, trailing-whitespace, mixed-line-ending: these
  wrap tools/hooks/check_files.py, which gains a --fix mode that
  rewrites staged files in place. Lefthook re-stages the fixes via
  stage_fixed: true, so the next commit naturally includes the
  cleanup. The user no longer has to manually strip whitespace,
  append newlines, or normalize line endings.

- web-eslint: ESLint --fix is enabled; safe auto-fixes are applied,
  warnings still surface.

trailing-whitespace now uses a regex ([ \t]+(?=\r?\n|$)) so it
correctly detects/strips whitespace before a line terminator and
preserves CRLF when only stripping whitespace. A previous
splitlines-based rstrip pass would silently miss
whitespace-before-newline.

Checks that only validate (json, yaml) or detect states that need
human review (case-conflict, merge-conflict, broken symlinks)
remain check-only; their --fix flag is accepted but a no-op.

ruff check/format, gofmt, and web-prettier already auto-fixed in
the previous config and were left unchanged.

fix
yuzhichang added a commit to yuzhichang/ragflow that referenced this pull request Jun 30, 2026
Ports 5 S-effort PRs from .claude/plans/review-and-port-py-agent-changes.md
Execution snapshot (all merged upstream) to the Go agent side.

Group 1 - tool ports
- infiniflow#15609 ExeSQL SSRF guard: add ValidateDBHost to tool/ssrf.go and
  wire into exesql.InvokableRun. Loopback, link-local, RFC1918, and
  empty host are rejected before any driver dispatch. Allowed hosts
  are dialed via the validated/resolved public IP (DNS-pin).
- infiniflow#15436 HTTP timeout: Go side already routes github/qweather/tushare
  through HTTPHelper (client.Timeout: 30s + per-stage timeouts) and
  jin10 is a stub. Added regression guard tests: default client
  timeout, stage timeouts, and AST scan for bare http.Get/Post calls
  outside the helper.

Group 2 - component ports
- infiniflow#16363 be_output restore + DeepL error: add BeOutput(v) helper
  returning {"content": v} frame; add DeepL translation-failure
  regression test using rewriteHostTransport (avoids mutating
  package globals which raced TestDeepL_BuildRequest).
- infiniflow#15644 Switch no longer matches empty condition: evaluateGroup
  empty-clauses short-circuit now returns false (was true) so an
  "and" condition with no clauses falls through to the next
  condition or end_cpn_ids instead of routing to the empty
  group's "to" target. Mirrors the all([]) is True fix.

Group 4 - API ports
- infiniflow#15374 session_id bind to path agent_id: Go DAO already enforces
  WHERE id = ? AND dialog_id = ? (stronger than the Python
  post-fetch check). Added 3 IDOR regression tests at the service
  level (Get/Get mismatch/Delete) confirming the binding holds.

Total: 32 new tests across 4 new test files. All agent/tool and
agent/component tests pass (320 + 331). All new service IDOR
tests pass (3/3). The one failing test in agent/component
(TestAgent_ReActExhaustsSteps) is a pre-existing flaky test that
also fails on the baseline without my changes.

Refs: .claude/plans/review-and-port-py-agent-changes.md
Refs: infiniflow#15609 infiniflow#15436 infiniflow#16363 infiniflow#15644 infiniflow#15374

Apply unstaged agent-go-port prep work

docker/.env
  - switch API_PROXY_SCHEME from python to go (Go server is the default)
  - enable SANDBOX_ENABLED=1 and extend COMPOSE_PROFILES with ragflow-go

web/CLAUDE.md
  - document frontend agent conventions: CSS/flex layout debugging,
    scope boundaries, i18n language files, query-key factory pattern,
    request layering (hook -> service -> next-request), shared UI lock,
    utility libs (dayjs, ahooks, lodash)

web/.agents/skills/tanstack-query-best-practices/
  - remove the full tanstack-query-best-practices skill set
    (SKILL.md + 21 rule files, 1,535 lines total)

Lefthook pre-commit was satisfied after stripping two pre-existing
trailing-whitespace lines from docker/.env comments.

chore(hooks): enable auto-fix for staged file checks

Convert lefthook pre-commit to B-mode (check + auto-fix in place)
for the four fixable jobs:

- end-of-file-fixer, trailing-whitespace, mixed-line-ending: these
  wrap tools/hooks/check_files.py, which gains a --fix mode that
  rewrites staged files in place. Lefthook re-stages the fixes via
  stage_fixed: true, so the next commit naturally includes the
  cleanup. The user no longer has to manually strip whitespace,
  append newlines, or normalize line endings.

- web-eslint: ESLint --fix is enabled; safe auto-fixes are applied,
  warnings still surface.

trailing-whitespace now uses a regex ([ \t]+(?=\r?\n|$)) so it
correctly detects/strips whitespace before a line terminator and
preserves CRLF when only stripping whitespace. A previous
splitlines-based rstrip pass would silently miss
whitespace-before-newline.

Checks that only validate (json, yaml) or detect states that need
human review (case-conflict, merge-conflict, broken symlinks)
remain check-only; their --fix flag is accepted but a no-op.

ruff check/format, gofmt, and web-prettier already auto-fixed in
the previous config and were left unchanged.
yuzhichang added a commit that referenced this pull request Jun 30, 2026
)

Mirrors 14 merged upstream PRs into the Go agent port.

PRs ported:
  - #15609 ExeSQL SSRF guard + DNS pin
  - #15436 HTTP timeout on external API tools
  - #16363 be_output restore + DeepL error path
  - #15644 switch no longer matches empty condition
  - #15374 session_id bind to path agent_id (DAO idor guard)
  - #16169 sandbox artifact ownership gate
  - #15457 tenant ownership on agentbots
  - #15145 rerun agent document access check
- #15446 thinking switch (component portion; provider policy lives in
internal/llm)
  - #15426 Invoke URL/proxy SSRF + DNS pin + no-redirects
  - #15238 agentbot thinking-logs beta endpoint
  - #14589 UserFillUp SSE event propagation
  - #14890 anonymous webhook opt-in
- #15068 PipelineChunker new component (text/file_ref/parser_id
dispatch; file-format extraction is a follow-up)

40 files, +2355 / -58 lines. 33 new tests, all targeted package suites
pass (1721 + 4 skipped); 1 pre-existing flaky test unrelated.
yuzhichang added a commit to ondery/ragflow that referenced this pull request Jul 1, 2026
…sion/user + input/output to Langfuse for agent runs

Rebuilt on current upstream/main after force-push; cherry-pick of the 7
PR-original commits collapsed into a single net diff to avoid conflicts
with intervening commits pulled in by repeated merges of upstream/main.

Original PR work (commits dropped during rebuild because their content
already lives on upstream/main or was a merge of upstream/main):
  c7339ae Enhance LLMService with token usage reporting
  0266cf0 Implement token usage tracking and Langfuse integration
  ab2b267 Include session_id in run_kwargs
  8bf937c Implement token usage tracking in chat model
  c955988 Enhance token tracking with context variables and functions
  3e88ed5 fix(agent): address CodeRabbit review on token usage tracking
  74b8c8c fix(agent): address CodeRabbit follow-up review

Forced-upstream duplicates dropped (already merged to main):
  70546ea (infiniflow#16396), 5b09910 (infiniflow#16403), 5d7f0fd (infiniflow#16405),
  730f33b (infiniflow#16407), a06343e (infiniflow#16408), f90be41 (infiniflow#16410),
  c4fe68e (infiniflow#16409), d4a0e71 (infiniflow#14773), ef42fd7 (infiniflow#15436),
  ab1015d (infiniflow#16363), db188cc (infiniflow#15446), 56ece68 (infiniflow#15609),
  2589b6e (infiniflow#15644), 74c2944 (infiniflow#15374), 78832ff (infiniflow#14985),
  bf18b59 (infiniflow#15457), 6c87225 (infiniflow#14890), e16d1a0 (infiniflow#15426),
  4712fcb (infiniflow#16169), 0536233 (infiniflow#14589), 08c807a (infiniflow#15145)

Plus 18 'Merge branch main into main' commits dropped (polluted topology).
yuzhichang added a commit to ondery/ragflow that referenced this pull request Jul 1, 2026
…sion/user + input/output to Langfuse for agent runs

Rebuilt on current upstream/main after force-push; cherry-pick of the 7
PR-original commits collapsed into a single net diff to avoid conflicts
with intervening commits pulled in by repeated merges of upstream/main.

Original PR work (commits dropped during rebuild because their content
already lives on upstream/main or was a merge of upstream/main):
  c7339ae Enhance LLMService with token usage reporting
  0266cf0 Implement token usage tracking and Langfuse integration
  ab2b267 Include session_id in run_kwargs
  8bf937c Implement token usage tracking in chat model
  c955988 Enhance token tracking with context variables and functions
  3e88ed5 fix(agent): address CodeRabbit review on token usage tracking
  74b8c8c fix(agent): address CodeRabbit follow-up review

Forced-upstream duplicates dropped (already merged to main):
  70546ea (infiniflow#16396), 5b09910 (infiniflow#16403), 5d7f0fd (infiniflow#16405),
  730f33b (infiniflow#16407), a06343e (infiniflow#16408), f90be41 (infiniflow#16410),
  c4fe68e (infiniflow#16409), d4a0e71 (infiniflow#14773), ef42fd7 (infiniflow#15436),
  ab1015d (infiniflow#16363), db188cc (infiniflow#15446), 56ece68 (infiniflow#15609),
  2589b6e (infiniflow#15644), 74c2944 (infiniflow#15374), 78832ff (infiniflow#14985),
  bf18b59 (infiniflow#15457), 6c87225 (infiniflow#14890), e16d1a0 (infiniflow#15426),
  4712fcb (infiniflow#16169), 0536233 (infiniflow#14589), 08c807a (infiniflow#15145)

Plus 18 'Merge branch main into main' commits dropped (polluted topology).

Co-authored-by: yzc <[email protected]>
xugangqiang pushed a commit to xugangqiang/ragflow that referenced this pull request Jul 1, 2026
…iniflow#16455)

Mirrors 14 merged upstream PRs into the Go agent port.

PRs ported:
  - infiniflow#15609 ExeSQL SSRF guard + DNS pin
  - infiniflow#15436 HTTP timeout on external API tools
  - infiniflow#16363 be_output restore + DeepL error path
  - infiniflow#15644 switch no longer matches empty condition
  - infiniflow#15374 session_id bind to path agent_id (DAO idor guard)
  - infiniflow#16169 sandbox artifact ownership gate
  - infiniflow#15457 tenant ownership on agentbots
  - infiniflow#15145 rerun agent document access check
- infiniflow#15446 thinking switch (component portion; provider policy lives in
internal/llm)
  - infiniflow#15426 Invoke URL/proxy SSRF + DNS pin + no-redirects
  - infiniflow#15238 agentbot thinking-logs beta endpoint
  - infiniflow#14589 UserFillUp SSE event propagation
  - infiniflow#14890 anonymous webhook opt-in
- infiniflow#15068 PipelineChunker new component (text/file_ref/parser_id
dispatch; file-format extraction is a follow-up)

40 files, +2355 / -58 lines. 33 new tests, all targeted package suites
pass (1721 + 4 skipped); 1 pre-existing flaky test unrelated.
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. 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