close
Skip to content

fix: preserve chatflow id on API create#6419

Open
puneetdixit200 wants to merge 2 commits into
FlowiseAI:mainfrom
puneetdixit200:bugfix/preserve-chatflow-api-id
Open

fix: preserve chatflow id on API create#6419
puneetdixit200 wants to merge 2 commits into
FlowiseAI:mainfrom
puneetdixit200:bugfix/preserve-chatflow-api-id

Conversation

@puneetdixit200
Copy link
Copy Markdown

Summary

  • Preserve an explicit chatflow id when creating a chatflow through the API, so exported flows can be restored with their original ID.
  • Validate caller-provided IDs and reject duplicates before saving, avoiding accidental updates through the create path.
  • Add controller and service coverage for the create-ID path.

Fixes #6418

Testing

  • npx --yes pnpm@10.26.0 --filter flowise-components build
  • npx --yes pnpm@10.26.0 --dir packages/server exec jest src/controllers/chatflows/index.test.ts --runInBand
  • npx --yes pnpm@10.26.0 --dir packages/server exec jest src/services/chatflows/index.test.ts --runInBand
  • npx --yes pnpm@10.26.0 exec prettier --check packages/server/src/controllers/chatflows/index.ts packages/server/src/controllers/chatflows/index.test.ts packages/server/src/services/chatflows/index.ts packages/server/src/services/chatflows/index.test.ts
  • npx --yes pnpm@10.26.0 exec eslint packages/server/src/controllers/chatflows/index.ts packages/server/src/controllers/chatflows/index.test.ts packages/server/src/services/chatflows/index.ts packages/server/src/services/chatflows/index.test.ts
  • git diff --check

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request enables the preservation of caller-provided IDs during chatflow creation, which is necessary for importing flows. It introduces validation logic to ensure that provided IDs are valid UUIDs and do not conflict with existing records, along with comprehensive unit tests for both the controller and service layers. Review feedback identifies that using Object.prototype.hasOwnProperty.call on a class instance may be unreliable due to TypeScript property initialization behavior and suggests using a nullish check instead.

Comment thread packages/server/src/services/chatflows/index.ts Outdated
@puneetdixit200
Copy link
Copy Markdown
Author

Pushed fedbfab to apply the review suggestion: the service now treats only a non-nullish id as caller-provided, with a regression test for id: undefined.

Verified:

  • COREPACK_ENABLE_STRICT=0 corepack pnpm@10.26.0 --dir packages/components build
  • COREPACK_ENABLE_STRICT=0 corepack pnpm@10.26.0 --dir packages/server test src/services/chatflows/index.test.ts --runInBand
  • git diff --check

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create a new chatflow using API not preserve id anymore

1 participant