Repository navigation
[dev] [tofikwest] feat/framework-control-link-isolation - #2829
Merged
Merged
Conversation
…nd retrieval - Updated ControlsController to accept frameworkInstanceId as an optional query parameter for findOne, linkPolicies, linkTasks, linkDocumentTypes, and unlinkDocumentType methods. - Enhanced ControlsService to handle frameworkInstanceId in findOne and linking methods, allowing for framework-specific control retrieval and linking. - Introduced new private methods to ensure framework instance validity and to fetch controls scoped to a specific framework. - Updated tests to cover new functionality and ensure proper linking behavior with framework context.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
6 issues found across 41 files
Confidence score: 2/5
- There are multiple high-confidence, user-impacting issues (severity 7/10) across core API paths, so merge risk is elevated despite being fixable.
- The most severe risk is non-atomic creation in
apps/api/src/framework-editor/control-template/control-template.service.ts: a control template can be persisted beforereplaceDocumentTypeLinksfails, potentially leaving orphaned database records. - Response-shape and data-correctness regressions are likely:
apps/api/src/frameworks/frameworks.service.tsmay leak raw relation arrays to clients, andapps/api/src/controls/controls.service.tsmay include archived policies/tasks due to a missingarchivedAtfilter. - Pay close attention to
apps/api/src/framework-editor/control-template/control-template.service.ts,apps/api/src/frameworks/frameworks.service.ts, andapps/api/src/controls/controls.service.ts- they carry data integrity, API contract, and filtering correctness risks.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="apps/api/src/framework-editor/control-template/control-template.service.ts">
<violation number="1" location="apps/api/src/framework-editor/control-template/control-template.service.ts:109">
P1: Non-atomic create: if `documentTypes` is provided but `frameworkId` is missing/invalid, the control template is already persisted before `replaceDocumentTypeLinks` throws. This leaves an orphaned record in the database.
Validate `frameworkId` before creating the control template, or wrap both operations in a transaction.</violation>
</file>
<file name="apps/api/src/framework-editor/task-template/task-template.service.ts">
<violation number="1" location="apps/api/src/framework-editor/task-template/task-template.service.ts:107">
P2: Prisma's `findUniqueOrThrow` throws a Prisma-specific error (not an HTTP exception), which will surface as a 500 to the client. Wrap these calls or use `findUnique` + explicit `NotFoundException` to return a proper 404, consistent with the `findById` pattern used for the task template.</violation>
</file>
<file name="apps/api/src/framework-editor/control-template/control-template.controller.ts">
<violation number="1" location="apps/api/src/framework-editor/control-template/control-template.controller.ts:127">
P2: Add `ParseEnumPipe` to validate `formType` at runtime, matching the pattern in `controls.controller.ts`.</violation>
</file>
<file name="apps/api/src/frameworks/frameworks.service.ts">
<violation number="1" location="apps/api/src/frameworks/frameworks.service.ts:188">
P1: Raw `frameworkPolicyLinks` and `frameworkDocumentLinks` arrays leak into the API response. The `...controlData` spread only strips `requirementsMapped`, so the new included relations pass through to consumers alongside the processed `policies` / `controlDocumentTypes` fields.
Strip them in the destructure to avoid exposing internal link-table structure.</violation>
</file>
<file name="apps/api/src/controls/controls.service.ts">
<violation number="1" location="apps/api/src/controls/controls.service.ts:212">
P1: Missing `archivedAt` filter on policies/tasks fetched through framework link tables. Unlike `findOne` which explicitly filters `{ archivedAt: null }`, this query will include archived policies and tasks in the response and progress calculation.</violation>
</file>
<file name="apps/api/src/frameworks/frameworks-source-loader.helper.ts">
<violation number="1" location="apps/api/src/frameworks/frameworks-source-loader.helper.ts:251">
P2: Framework policy/task/document links may be silently dropped if a control has links for a framework but no requirements from that framework in the filtered set. Consider also deriving `frameworkIds` from `frameworkPolicyLinks`, `frameworkTaskLinks`, and `frameworkDocumentLinks` to ensure no framework-specific links are lost.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.
…er for document type linking - Updated ControlTemplateService to streamline the creation and updating of control templates, ensuring proper handling of document types. - Refactored methods to utilize transactions for creating and linking document types, improving data integrity. - Enhanced ControlTemplateController to enforce validation on formType parameters using ParseEnumPipe. - Updated tests to reflect changes in service logic and ensure robust coverage for new functionality.
Contributor
|
@cubic-dev-ai review it |
Contributor
@tofikwest I have started the AI code review. It will take a few minutes to complete. |
Contributor
|
🎉 This PR is included in version 3.52.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
3 of 5 tasks
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is an automated pull request to merge feat/framework-control-link-isolation into dev.
It was created by the [Auto Pull Request] action.
Summary by cubic
Scopes control-to-policy/task/document links by framework and framework instance to prevent cross-framework bleed. Adds scoped link models, framework-aware APIs, and editor support, including document-type linking on control templates.
New Features
frameworkInstanceIdfor fetch/link/unlink; editor link endpoints acceptframeworkIdfor policies, tasks, and document types with enum validation and transactional linking.frameworkInstanceId/frameworkIdand fetch scoped control details.Migration
frameworkInstanceIdwhen fetching or linking control details in the org app, andframeworkIdwhen linking (including document types) in the framework editor.openapi.jsonchanges.Written for commit a024822. Summary will update on new commits.