Skip to content

fix: validate chat data ids before run#6936

Draft
xqvvu wants to merge 2 commits into
mainfrom
xqvvu/stream-resume-dataid-validation
Draft

fix: validate chat data ids before run#6936
xqvvu wants to merge 2 commits into
mainfrom
xqvvu/stream-resume-dataid-validation

Conversation

@xqvvu
Copy link
Copy Markdown
Collaborator

@xqvvu xqvvu commented May 14, 2026

Summary

  • add a shared chat dataId validation helper for the current human/AI round
  • reject human and assistant using the same dataId before workflow execution
  • reject current-round dataIds that already exist in chat_items before workflow execution
  • wire the check into v1 chat completions, v2 chat completions, and chatTest
  • keep the final unique-index/data migration work for the follow-up PR

Tests

  • pnpm --filter @fastgpt/service test test/core/chat/dataIdValidation.test.ts
  • pnpm --filter @fastgpt/app typecheck
  • pnpm exec eslint --fix "projects/app/src/pages/api/core/chat/chatTest.ts" "projects/app/src/pages/api/v1/chat/completions.ts" "projects/app/src/pages/api/v2/chat/completions.ts" "packages/service/core/chat/dataIdValidation.ts" "packages/service/test/core/chat/dataIdValidation.test.ts"

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 14, 2026

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 14.03% 1140 / 8124
🔵 Statements 14.02% 1195 / 8523
🔵 Functions 12.52% 245 / 1956
🔵 Branches 11.98% 536 / 4472
File CoverageNo changed files found.
Generated in workflow #256 for commit fb54317 by the Vitest Coverage Report Action

@xqvvu xqvvu marked this pull request as draft May 14, 2026 08:59
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 14, 2026

Coverage Report for global

Status Category Percentage Covered / Total
🔵 Lines 89.92% 2295 / 2552
🔵 Statements 89.02% 2506 / 2815
🔵 Functions 93.13% 434 / 466
🔵 Branches 84.54% 1679 / 1986
File CoverageNo changed files found.
Generated in workflow #928 for commit fb54317 by the Vitest Coverage Report Action

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 14, 2026

Coverage Report for service

Status Category Percentage Covered / Total
🔵 Lines 35.71% 4686 / 13119
🔵 Statements 35.42% 4957 / 13994
🔵 Functions 31.84% 876 / 2751
🔵 Branches 31.32% 2647 / 8451
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/service/core/chat/dataIdValidation.ts 96.42% 90% 100% 100% 47
Generated in workflow #928 for commit fb54317 by the Vitest Coverage Report Action

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 14, 2026

Coverage Report for app

Status Category Percentage Covered / Total
🔵 Lines 6.41% 1852 / 28890
🔵 Statements 6.22% 1986 / 31894
🔵 Functions 3.86% 384 / 9943
🔵 Branches 4.91% 1021 / 20788
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
projects/app/src/pages/api/core/chat/chatTest.ts 0% 0% 0% 0% 70-368
projects/app/src/pages/api/v1/chat/completions.ts 0% 0% 0% 0% 69-697
projects/app/src/pages/api/v2/chat/completions.ts 0% 0% 0% 0% 78-766
Generated in workflow #928 for commit fb54317 by the Vitest Coverage Report Action

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 14, 2026

Admin Preview Image Ready!

ghcr.io/labring/fastgpt-pr:admin_fb5431740d99ffea886879fe87ae763a1f0c173f

🕒 Time: 2026-05-18 12:13:11 (UTC+8)

@github-actions
Copy link
Copy Markdown

Build Successful - Preview code-sandbox Image for this PR:

ghcr.io/labring/fastgpt-pr:code-sandbox_fb5431740d99ffea886879fe87ae763a1f0c173f

🕒 Time: 2026-05-18 12:12:28 (UTC+8)

@github-actions
Copy link
Copy Markdown

Build Successful - Preview fastgpt Image for this PR:

ghcr.io/labring/fastgpt-pr:fastgpt_fb5431740d99ffea886879fe87ae763a1f0c173f

🕒 Time: 2026-05-18 12:12:36 (UTC+8)

@github-actions
Copy link
Copy Markdown

Build Successful - Preview mcp_server Image for this PR:

ghcr.io/labring/fastgpt-pr:mcp_server_fb5431740d99ffea886879fe87ae763a1f0c173f

🕒 Time: 2026-05-18 12:13:09 (UTC+8)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant