Skip to content

Conversation

HarshP4585
Copy link
Collaborator

@HarshP4585 HarshP4585 commented Oct 2, 2025

Describe your changes

  • Fix CRUD bugs

Write your issue number after "Fixes "

Fixes #2264. #2265, #2267

Please ensure all items are checked off before requesting a review:

  • I deployed the code locally.
  • I have performed a self-review of my code.
  • I have included the issue # in the PR.
  • I have labelled the PR correctly.
  • The issue I am working on is assigned to me.
  • I have avoided using hardcoded values to ensure scalability and maintain consistency across the application.
  • I have ensured that font sizes, color choices, and other UI elements are referenced from the theme.
  • My pull request is focused and addresses a single, specific feature.
  • If there are UI changes, I have attached a screenshot or video to this PR.

@HarshP4585 HarshP4585 self-assigned this Oct 2, 2025
@HarshP4585 HarshP4585 added bug Something isn't working backend Backend related tasks/issues labels Oct 2, 2025
Copy link
Contributor

coderabbitai bot commented Oct 2, 2025

Pre-merge checks and finishing touches

❌ Failed checks (3 warnings, 1 inconclusive)
Check name Status Explanation Resolution
Linked Issues Check ⚠️ Warning The validation utility changes described do not implement or address the issue of failing status updates for annexes and clauses via dropdowns (issue #2264), so the core objective of fixing that CRUD bug remains unfulfilled. Please include and demonstrate the specific code changes that resolve the status update failure for annexes and clauses as described in issue #2264, and confirm any related fixes for issues #2265 and #2267.
Out of Scope Changes Check ⚠️ Warning The PR currently includes broad changes to multiple validation modules (AI Trust Centre, ISO 27001, ISO 42001, and model inventory) that are unrelated to the linked CRUD status-update issues, indicating significant out-of-scope modifications. Please remove or relocate the unrelated validation refactors into a separate PR and focus this pull request solely on the code changes needed to fix the annex and clause status update bug.
Description Check ⚠️ Warning The description does not follow the repository template because it provides only a one-line summary, lacks details about what was changed and why, and misformats the issue references by mixing punctuation instead of using “Fixes #2264, #2265, and #2267.” Please expand the description to include a concise overview of the specific code changes and their purpose, correctly list all fixed issue numbers with “Fixes #…” syntax, and either complete or remove the unused checklist items before requesting review.
Title Check ❓ Inconclusive The title “Fix CRUD bugs” is overly generic and does not clearly describe the primary change or the specific bug being addressed, making it hard for reviewers to understand the main focus at a glance. Please update the title to concisely reflect the key fix, for example “Fix status update for annexes and clauses via dropdown” so that the main change is immediately clear.
✅ Passed checks (1 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch hp-oct-1-fix-crud-bugs

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 94a1088 and 65e24e0.

📒 Files selected for processing (4)
  • Servers/utils/validations/aiTrustCentreValidation.utils.ts (18 hunks)
  • Servers/utils/validations/iso27001Validation.utils.ts (8 hunks)
  • Servers/utils/validations/iso42001Validation.utils.ts (8 hunks)
  • Servers/utils/validations/modelInventoryValidation.utils.ts (9 hunks)
🧰 Additional context used
🧬 Code graph analysis (4)
Servers/utils/validations/aiTrustCentreValidation.utils.ts (2)
Servers/utils/validations/validation.utils.ts (2)
  • validateString (32-107)
  • ValidationError (12-17)
Servers/domain.layer/interfaces/i.aiTrustCentreOverview.ts (1)
  • IAITrustCentreOverview (1-53)
Servers/utils/validations/iso42001Validation.utils.ts (2)
Servers/utils/validations/iso27001Validation.utils.ts (4)
  • validateProjectId (125-130)
  • validateUserId (115-120)
  • validateUpdateSubClause (419-450)
  • updateSubClauseSchema (377-393)
Servers/utils/validations/validation.utils.ts (4)
  • ValidationResult (6-10)
  • validateForeignKey (316-355)
  • ValidationError (12-17)
  • validateSchema (360-383)
Servers/utils/validations/iso27001Validation.utils.ts (3)
Servers/utils/validations/iso42001Validation.utils.ts (4)
  • validateProjectId (172-177)
  • validateUserId (162-167)
  • validateUpdateSubClause (464-495)
  • updateSubClauseSchema (420-436)
Servers/utils/validations/projectValidation.utils.ts (1)
  • validateProjectId (295-297)
Servers/utils/validations/validation.utils.ts (4)
  • ValidationResult (6-10)
  • validateForeignKey (316-355)
  • ValidationError (12-17)
  • validateSchema (360-383)
Servers/utils/validations/modelInventoryValidation.utils.ts (1)
Servers/utils/validations/validation.utils.ts (3)
  • validateString (32-107)
  • ValidationResult (6-10)
  • validateForeignKey (316-355)
🔇 Additional comments (21)
Servers/utils/validations/aiTrustCentreValidation.utils.ts (7)

60-71: LGTM! Improved validation flexibility.

The conditional validation for the title field now correctly handles optional/empty cases, allowing updates without requiring a title to be provided.


73-94: LGTM! Color validation properly handles optional cases.

The header_color validation now appropriately skips validation when the field is undefined, null, or empty, while still enforcing format constraints when a value is provided.


96-102: LGTM! Logo file ID validation is now optional.

The logo field correctly allows empty/null values, which is appropriate for optional fields.


109-160: LGTM! Visibility-based validation for intro section.

The intro section validations now correctly check both the visibility flag and content presence before enforcing validation rules. This prevents validation errors when sections are hidden or empty.


164-215: LGTM! Visibility-based validation for company description.

The company description validations follow the same visibility-based pattern, ensuring validation only occurs when sections are visible and have content.


219-280: LGTM! Visibility-based validation for terms and contact.

The terms and contact section validations are consistent with the pattern established in other sections, checking visibility before validating content.


474-537: LGTM! Business rules align with field-level validation.

The business rules validation has been updated to check the parent visibility flags (intro_visible, company_description_visible, terms_and_contact_visible) before validating nested content, which is consistent with the field-level validation changes.

Servers/utils/validations/iso42001Validation.utils.ts (7)

169-177: LGTM! New validateProjectId function.

The new validateProjectId function follows the same pattern as validateUserId, treating undefined/null/empty as optional and validating as a foreign key otherwise.


433-435: LGTM! Schema updated to use named validators.

The updateSubClauseSchema now uses the named validateUserId and validateProjectId validators, which is cleaner than inline lambdas and consistent with the pattern used in iso27001Validation.utils.ts.


456-458: LGTM! Annex category schema updated consistently.

The updateAnnexCategorySchema follows the same pattern as updateSubClauseSchema, using named validators for consistency.


464-495: LGTM! Conditional validation for subclauses.

The validateUpdateSubClause function now accepts a skipFileFields parameter and conditionally filters out user_id and project_id from the schema when files are not present. This allows status updates without requiring file-related fields.


501-573: LGTM! Conditional validation for annex categories.

The validateUpdateAnnexCategory function implements the same skipFileFields pattern as validateUpdateSubClause, ensuring consistent behavior across both entity types.


607-645: LGTM! File-aware validation for subclause updates.

The validateCompleteSubClauseUpdate function now:

  1. Determines if files are present
  2. Skips user_id/project_id validation when no files
  3. Explicitly requires user_id/project_id when files are present

This correctly addresses the bug where these fields were required even for simple status updates.


650-688: LGTM! File-aware validation for annex category updates.

The validateCompleteAnnexCategoryUpdate function mirrors the pattern used in validateCompleteSubClauseUpdate, ensuring consistent validation behavior across entity types.

Servers/utils/validations/iso27001Validation.utils.ts (7)

122-130: LGTM! New validateProjectId function.

The validateProjectId function follows the same pattern as validateUserId and is identical to the implementation in iso42001Validation.utils.ts, ensuring consistency across frameworks.


390-392: LGTM! Schema updated to use named validators.

The updateSubClauseSchema now uses validateUserId and validateProjectId, matching the pattern in iso42001Validation.utils.ts.


411-413: LGTM! Annex control schema updated consistently.

The updateAnnexControlSchema follows the same pattern, ensuring consistency across all update schemas.


419-450: LGTM! Conditional validation for subclauses.

The validateUpdateSubClause function implements the skipFileFields pattern identically to the iso42001 version, ensuring consistent behavior across frameworks.


455-486: LGTM! Conditional validation for annex controls.

The validateUpdateAnnexControl function mirrors validateUpdateSubClause, maintaining consistency.


491-529: LGTM! File-aware validation for subclause updates.

The validateCompleteSubClauseUpdate function implements the same file-aware validation as the iso42001 version, correctly addressing the bug where user_id/project_id were required even for simple status updates.


534-572: LGTM! File-aware validation for annex control updates.

The validateCompleteAnnexControlUpdate function follows the established pattern, ensuring consistent validation across all entity types and frameworks.


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 and usage tips.

@swaleha456
Copy link
Contributor

LGTM!

@MuhammadKhalilzadeh MuhammadKhalilzadeh merged commit 65d3f31 into develop Oct 3, 2025
2 checks passed
@MuhammadKhalilzadeh MuhammadKhalilzadeh deleted the hp-oct-1-fix-crud-bugs branch October 3, 2025 07:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Backend related tasks/issues bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Failed to updated annexes and clauses using status Dropdowns
4 participants