Skip to content

Conversation

@gupta-piyush19
Copy link
Contributor

Description 📣

makes environments optional in project template

Type ✨

  • Bug fix
  • New feature
  • Improvement
  • Breaking change
  • Documentation

Tests 🛠️

# Here's some code block to paste some code snippets

@gupta-piyush19 gupta-piyush19 changed the title [ENG-4277] fix: makes environments optional in project template [ENG-4227] fix: makes environments optional in project template Nov 25, 2025
@maidul98
Copy link
Collaborator

maidul98 commented Nov 25, 2025

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Nov 25, 2025

Greptile Overview

Greptile Summary

This PR makes the environments field optional in project templates by removing the .min(1) array requirement and changing from .optional() to .nullish() validation.

Key changes:

  • Removes minimum array length requirement from ProjectTemplateEnvironmentsSchema
  • Changes validation from .optional() to .nullish() in CREATE endpoint

Issues found:

  • Missing early return in superRefine validation causes empty arrays to fail position validation checks
  • Empty array [] bypasses default environment fallback in service layer, potentially creating SecretManager templates with zero environments

Confidence Score: 2/5

  • This PR has logical errors that will cause validation failures for valid use cases
  • The removal of .min(1) without adding an early return in superRefine creates a bug where empty arrays fail validation. Additionally, empty arrays bypass the default environments fallback, which may not be the intended behavior for SecretManager projects.
  • backend/src/ee/routes/v1/project-template-router.ts requires fixes to handle empty arrays correctly

Important Files Changed

File Analysis

Filename Score Overview
backend/src/ee/routes/v1/project-template-router.ts 4/5 Removes min array length requirement and changes validation from optional to nullish for environments field

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Additional Comments (1)

  1. backend/src/ee/routes/v1/project-template-router.ts, line 75-93 (link)

    logic: missing early return for empty arrays - will fail validation checks on empty array

    The superRefine runs uniqueness/position validation even when environments is empty ([]). Since you removed .min(1), users can now send empty arrays which will fail the position validation on line 86-92.

1 file reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

@gupta-piyush19 gupta-piyush19 merged commit 9bd3151 into main Nov 27, 2025
10 checks passed
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.

4 participants