Skip to content

Commit

Permalink
fix(platform): Check if Env. Name is left empty (keyshade-xyz#646)
Browse files Browse the repository at this point in the history
Co-authored-by: Rajdip Bhattacharya <[email protected]>
  • Loading branch information
mrswastik-robot and rajdip-b authored Jan 20, 2025
1 parent fe862ab commit 5f3fac8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion apps/api/src/project/project.e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1416,7 +1416,7 @@ describe('Project Controller Tests', () => {
expect(devEnvironment.name).toBe(environment.name)

expect(defaultEnvironment).toBeDefined()
expect(defaultEnvironment.name).toBe('Default')
expect(defaultEnvironment.name).toBe('default')
})

it('should only copy new environments, secrets and variables if sync is not hard', async () => {
Expand Down
4 changes: 2 additions & 2 deletions apps/api/src/project/service/project.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@ export class ProjectService {
createEnvironmentOps.push(
this.prisma.environment.create({
data: {
name: 'Default',
name: 'default',
slug: await generateEntitySlug(
'Default',
'default',
'ENVIRONMENT',
this.prisma
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,19 @@ export default function CreateProjectDialogue(): JSX.Element {
// Function to create a new project
const createNewProject = useCallback(async () => {
if (selectedWorkspace) {
newProjectData.workspaceSlug = selectedWorkspace.slug
// Filter out environments with empty names
const projectData = {
...newProjectData,
workspaceSlug: selectedWorkspace.slug,
environments:
newProjectData.environments?.filter(
(env) => env.name.trim() !== ''
) || []
}

const { data, error, success } =
await ControllerInstance.getInstance().projectController.createProject(
newProjectData,
projectData,
{}
)

Expand Down

0 comments on commit 5f3fac8

Please sign in to comment.