Skip to content

Add pipeline draft CRUD endpoints for RDI instances - #6467

Merged
ArtemHoruzhenko merged 4 commits into
mainfrom
feature/rdi-ui/pipeline-draft-crud
Sep 10, 2026
Merged

Add pipeline draft CRUD endpoints for RDI instances#6467
ArtemHoruzhenko merged 4 commits into
mainfrom
feature/rdi-ui/pipeline-draft-crud

Conversation

@ArtemHoruzhenko

@ArtemHoruzhenko ArtemHoruzhenko commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

What

Third PR in the rdi-ui integration chain (stacked on #6465, which is stacked on #6464).

Adds a pipeline_draft table and CRUD endpoints under rdi/:id/pipeline-drafts (list/get/create/update/delete), so RDI pipeline work-in-progress can be persisted per instance ahead of the real rdi-ui component being wired in.

Key points:

  • Orphan removal: FK pipeline_draft.rdiInstanceId -> rdi.id with ON DELETE CASCADE at the DB level, mirroring the query-library module's existing FK-to-parent pattern. No manual cleanup code needed when an RDI instance is deleted.
  • Encryption: data is encrypted at rest via the existing ModelEncryptor, same mechanism as RdiEntity.password and QueryLibraryEntity's fields.
  • JSON, not string: the entity column has to stay a text/string column (encryption only operates on strings), but it's decorated with the existing @DataAsJsonString() decorator so every layer above the entity (API model, DTOs, controllers) works with a real JSON object, not a string — same mechanism already used by AiQueryMessageEntity.steps. Structure of the JSON itself is intentionally not validated/typed.
  • Multiple drafts per RDI instance are supported (not a 1:1 relationship), with a full update endpoint (not just create/delete).
  • Followed RdiPipelineController's existing rdi/:id/... nesting convention and query-library's repository/service/controller layering as templates.

Testing

  • npm run lint:api and npm run type-check --prefix redisinsight/api (0 new errors) pass.
  • 3 new spec files (26 tests) covering the repository (incl. cascade-relevant FK setup, encryption interaction, and a dedicated test proving the entity round-trips data as JSON string internally while exposing a real object externally), service, and controller.
  • Full rdi module test suite (286 tests) still passes.

No ticket yet.


Note

Medium Risk
New encrypted persistence and CRUD surface for RDI draft data; repository edge cases around decrypt failures affect data visibility and updates, but patterns match existing RDI/query-library modules.

Overview
Adds persisted RDI pipeline drafts so in-progress pipeline JSON can be saved per instance before the UI is wired up.

A new pipeline_draft table (migration + TypeORM entity) stores encrypted draft data keyed by rdiInstanceId, with ON DELETE CASCADE when an RDI instance is removed. The API exposes full CRUD at rdi/:id/pipeline-drafts, using the existing RequestRdiClientMetadata nesting and validation (create whitelists body fields; update rejects explicit null for data). Create verifies the parent RDI exists via RdiRepository.get(..., true) without decrypting credentials.

Persistence goes through LocalPipelineDraftRepository, which encrypts data with ModelEncryptor, exposes JSON objects via @DataAsJsonString(), skips undecryptable rows on list, and avoids overwriting ciphertext on failed decrypt during update. RdiModule and ORM config register the new stack; controller/service/repository specs cover the behavior.

Reviewed by Cursor Bugbot for commit e20ca94. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Code Coverage - Backend unit tests

St.
Category Percentage Covered / Total
🟢 Statements 93.27% 16801/18013
🟡 Branches 75.64% 5411/7154
🟢 Functions 87.69% 2579/2941
🟢 Lines 93.13% 16070/17255

Test suite run success

3829 tests passing in 328 suites.

Report generated by 🧪jest coverage report action from e20ca94

@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Code Coverage - Integration Tests

Status Category Percentage Covered / Total
🟡 Statements 79.72% 18542/23256
🟡 Branches 62.16% 8681/13965
🟡 Functions 67.52% 2514/3723
🟡 Lines 79.33% 17463/22011

@ArtemHoruzhenko
ArtemHoruzhenko force-pushed the feature/rdi-ui/pipeline-draft-crud branch from 477b475 to d40b4db Compare September 1, 2026 09:42
@ArtemHoruzhenko
ArtemHoruzhenko force-pushed the feature/rdi-ui/pipeline-draft-crud branch from d40b4db to 0d3bf38 Compare September 1, 2026 10:13
@ArtemHoruzhenko
ArtemHoruzhenko marked this pull request as ready for review September 8, 2026 15:51
@ArtemHoruzhenko
ArtemHoruzhenko requested a review from a team as a code owner September 8, 2026 15:51

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0d3bf38753

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread redisinsight/api/src/modules/rdi/repository/local.pipeline-draft.repository.ts Outdated

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

@ArtemHoruzhenko
ArtemHoruzhenko force-pushed the feature/rdi-ui/pipeline-draft-crud branch from 0d3bf38 to c4db648 Compare September 8, 2026 16:42

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c4db648d2f

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread redisinsight/api/src/modules/rdi/dto/update.pipeline-draft.dto.ts Outdated
Comment thread redisinsight/api/src/modules/rdi/entities/pipeline-draft.entity.ts
@ArtemHoruzhenko
ArtemHoruzhenko force-pushed the feature/rdi-ui/pipeline-draft-crud branch from c4db648 to 7aabd35 Compare September 8, 2026 16:55

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0d988a4dfe

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread redisinsight/api/src/modules/rdi/repository/local.pipeline-draft.repository.ts Outdated
Comment thread redisinsight/api/src/modules/rdi/pipeline-draft.service.ts Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 39afac0654

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 39afac0. Configure here.

@ArtemHoruzhenko
ArtemHoruzhenko force-pushed the feature/rdi-ui/pipeline-draft-crud branch from 39afac0 to ae0e0c1 Compare September 9, 2026 12:29

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ae0e0c1955

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Base automatically changed from feature/rdi-ui/pipeline-management-v2-route to main September 10, 2026 09:43
Adds a pipeline_draft table and list/get/create/update/delete
endpoints under rdi/:id/pipeline-drafts, so RDI pipeline work-in-
progress can be persisted per instance. Drafts are orphan-removed via
a DB-level ON DELETE CASCADE FK to the rdi table (mirroring the
query-library module's FK pattern), and data is encrypted at rest via
the existing ModelEncryptor. The data column is stored as a JSON
string (required since encryption only operates on strings) but
exposed as a real object at the API model layer via the existing
DataAsJsonString decorator, the same mechanism already used by
AiQueryMessageEntity.steps.
Enables ValidationPipe whitelisting on the pipeline-draft controller so
an unexpected id field on a create/update body can no longer overwrite
an unrelated draft via TypeORM's upsert-on-save behavior.

Fixes update() double-encoding the persisted data column when a PATCH
omits data: the already-JSON-stringified value was being routed back
through @DataAsJsonString(), stringifying it a second time.
Rejects null data on PATCH instead of silently treating it as omitted
(PartialType's IsOptional skips validation for null the same as
undefined). Validates the parent RDI instance exists before creating a
draft, translating a missing/deleted instance into a 404 instead of an
uncaught foreign-key constraint error. Declares the entity's index to
match the migration so schema-diff tooling doesn't see it as
extraneous. Stops tolerating decrypt failures in update(), since
silently swallowing them would overwrite valid ciphertext with null.
Excludes drafts whose data decrypt returned null due to an encryption
strategy mismatch, rather than only handling decrypt exceptions - the
plain strategy returns null instead of throwing when the stored value
was encrypted with a different strategy.

Uses the existence-only RDI lookup for the parent check in create(),
so a draft can still be created even if the RDI instance's stored
credentials can no longer be decrypted.
@ArtemHoruzhenko
ArtemHoruzhenko force-pushed the feature/rdi-ui/pipeline-draft-crud branch from ae0e0c1 to e20ca94 Compare September 10, 2026 09:54

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e20ca94fb7

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@ArtemHoruzhenko
ArtemHoruzhenko merged commit 6e9d71f into main Sep 10, 2026
30 checks passed
@ArtemHoruzhenko
ArtemHoruzhenko deleted the feature/rdi-ui/pipeline-draft-crud branch September 10, 2026 10:43
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.

2 participants