Conversation
| if (storageRules.enableLocalVault) { | ||
| return 'local'; | ||
| } | ||
| return 'remote'; |
There was a problem hiding this comment.
getDefaultProjectStorageType can return 'remote' for git projects even when enableCloudSync is false, producing a default storage type that violates storageRules.
Details
✨ AI Reasoning
The function is choosing a default storage mode based on enabled rule flags and current project type. In one branch, the fallback path selects a mode even when that mode may be disabled by the provided flags. That means some valid inputs lead to a result that contradicts the rule configuration, so downstream code may treat a forbidden storage type as the default.
🔧 How do I fix it?
Trace execution paths carefully. Ensure precondition checks happen before using values, validate ranges before checking impossible conditions, and don't check for states that the code has already ruled out.
Reply @AikidoSec feedback: [FEEDBACK] to get better review comments in the future.
Reply @AikidoSec ignore: [REASON] to ignore this issue.
More info
| if (storageRules.enableLocalVault) { | ||
| return 'local'; | ||
| } | ||
| return 'git'; |
There was a problem hiding this comment.
getDefaultProjectStorageType can return 'git' for remote projects even when enableGitSync is false, yielding a default that conflicts with storageRules.
Show fix
| return 'git'; | |
| if (storageRules.enableGitSync) { | |
| return 'git'; | |
| } | |
| return 'local'; |
Details
✨ AI Reasoning
The branch intended for existing remote projects includes a fallback that does not validate whether the selected mode is enabled. This makes the function output a mode that can be disallowed by the same rules object, creating a concrete mismatch between policy and computed default.
Reply @AikidoSec feedback: [FEEDBACK] to get better review comments in the future.
Reply @AikidoSec ignore: [REASON] to ignore this issue.
More info
a88f15a to
27cfd81
Compare
✨ Circular References ReportGenerated at: 2026-03-24T04:06:37.194Z Summary
✨ Circular References Removed (1)Click to expand/collapseClick to view all circular references in PR (73)Click to view all circular references in base branch (74)Analysis✨ Great Job! This PR removes 1 circular reference. Keep up the good work! This report was generated automatically by comparing against the |
| export const isLocalProject = (project: Pick<Project, 'remoteId'>): project is LocalProject => | ||
| project.remoteId === null; |
There was a problem hiding this comment.
isLocalProject treats any remoteId === null project as local, which also matches GitProject. This misclassifies git projects and breaks the type guard’s correctness.
| export const isLocalProject = (project: Pick<Project, 'remoteId'>): project is LocalProject => | |
| project.remoteId === null; | |
| export const isLocalProject = (project: Pick<Project, 'remoteId' | 'gitRepositoryId'>): project is LocalProject => | |
| project.remoteId === null && project.gitRepositoryId === null; |
Details
✨ AI Reasoning
The type guard for determining whether a project is local relies only on remoteId === null. In the declared model, git-backed projects also have remoteId set to null, so they are guaranteed to be classified as local by this guard. That makes the guard's narrowing behavior inconsistent with the actual project variants and can lead to incorrect control-flow decisions anywhere this predicate is used.
Reply @AikidoSec feedback: [FEEDBACK] to get better review comments in the future.
Reply @AikidoSec ignore: [REASON] to ignore this issue.
More info
There was a problem hiding this comment.
Pull request overview
Migrates the legacy Project model out of packages/insomnia/src/models/project.ts into the insomnia-data layer, updating the app to use insomnia-data model metadata/type-guards (models.project.*) and CRUD via services.project.*.
Changes:
- Removed the legacy
Projectmodel module and re-homed Project types/constants/type-guards under~/insomnia-data(models.project). - Added a
projectservice implementation ininsomnia-data(Node impl) and updated routes/UI/tests to useservices.project.*for CRUD. - Moved
getDefaultProjectStorageType/getProjectStorageTypeLabelintoinsomnia-dataexports and updated call sites.
Reviewed changes
Copilot reviewed 93 out of 93 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/insomnia/src/utils/router.ts | Uses services.project.getById and models.project.SCRATCHPAD_PROJECT_ID while keeping DB queries typed with Project. |
| packages/insomnia/src/ui/organization-utils.ts | Switches project create/update operations to services.project.*. |
| packages/insomnia/src/ui/hooks/use-insomnia-tab.ts | Updates Project type import to come from ~/insomnia-data. |
| packages/insomnia/src/ui/components/settings/import-export.tsx | Updates Project type import to ~/insomnia-data. |
| packages/insomnia/src/ui/components/settings/credentials.tsx | Types related-projects response as Project[] from ~/insomnia-data. |
| packages/insomnia/src/ui/components/project/project-type-warning.tsx | Uses getProjectStorageTypeLabel from ~/insomnia-data. |
| packages/insomnia/src/ui/components/project/project-settings-form.tsx | Uses getDefaultProjectStorageType + models.project.* helpers from ~/insomnia-data. |
| packages/insomnia/src/ui/components/project/project-list-sidebar.tsx | Uses models.project.isRemoteProject/isGitProject and scratchpad constant from ~/insomnia-data. |
| packages/insomnia/src/ui/components/modals/workspace-settings-modal.tsx | Replaces isGitProject helper with models.project.isGitProject. |
| packages/insomnia/src/ui/components/modals/workspace-environments-edit-modal.tsx | Replaces isRemoteProject helper with models.project.isRemoteProject. |
| packages/insomnia/src/ui/components/modals/workspace-duplicate-modal.tsx | Updates Project type import to ~/insomnia-data. |
| packages/insomnia/src/ui/components/modals/project-modal.tsx | Updates Project type import to ~/insomnia-data. |
| packages/insomnia/src/ui/components/modals/new-workspace-modal.tsx | Replaces isGitProject helper with models.project.isGitProject; updates Project type import. |
| packages/insomnia/src/ui/components/modals/import-modal/import-projects-modal.tsx | Updates Project type import to ~/insomnia-data. |
| packages/insomnia/src/ui/components/modals/import-modal/import-modal.tsx | Uses models.project.isScratchpadProject from ~/insomnia-data. |
| packages/insomnia/src/ui/components/modals/add-request-to-collection-modal.tsx | Updates Project type import to ~/insomnia-data. |
| packages/insomnia/src/ui/components/modals/tests/import-export.test.ts | Replaces models.project.all() with services.project.all(). |
| packages/insomnia/src/ui/components/mcp/mcp-url-bar.tsx | Updates Project type import to ~/insomnia-data. |
| packages/insomnia/src/ui/components/environment-picker.tsx | Replaces isRemoteProject helper with models.project.isRemoteProject. |
| packages/insomnia/src/ui/components/dropdowns/workspace-sync-dropdown.tsx | Replaces isRemoteProject/isGitProject helpers with models.project.*. |
| packages/insomnia/src/ui/components/dropdowns/workspace-dropdown.tsx | Uses models.project.isRemoteProject in delete messaging. |
| packages/insomnia/src/ui/components/dropdowns/workspace-card-dropdown.tsx | Uses models.project.isRemoteProject to control delete options. |
| packages/insomnia/src/ui/components/dropdowns/sync-dropdown.tsx | Updates Project type import to ~/insomnia-data. |
| packages/insomnia/src/ui/components/dropdowns/project-dropdown.tsx | Uses models.project.* helpers and getProjectStorageTypeLabel from ~/insomnia-data. |
| packages/insomnia/src/ui/components/dropdowns/git-project-sync-dropdown.tsx | Updates GitProject type import to ~/insomnia-data. |
| packages/insomnia/src/templating/types.ts | Updates Project type import to ~/insomnia-data. |
| packages/insomnia/src/sync/vcs/pull-backend-project.ts | Updates RemoteProject type import to ~/insomnia-data. |
| packages/insomnia/src/sync/vcs/migrate-projects-into-organization.ts | Uses services.project.update and models.project constants/types. |
| packages/insomnia/src/sync/vcs/initialize-backend-project.ts | Updates Project type import to ~/insomnia-data. |
| packages/insomnia/src/sync/git/tests/ne-db-client.test.ts | Replaces models.project.create with services.project.create. |
| packages/insomnia/src/routes/untracked-projects.tsx | Updates Project type import to ~/insomnia-data. |
| packages/insomnia/src/routes/remote-files.tsx | Updates Project type import to ~/insomnia-data. |
| packages/insomnia/src/routes/organization.sync-organizations-and-projects.tsx | Updates Project type import to ~/insomnia-data. |
| packages/insomnia/src/routes/organization.$organizationId.project.new.tsx | Uses services.project.create and models.project.EMPTY_GIT_PROJECT_ID. |
| packages/insomnia/src/routes/organization.$organizationId.project._index.tsx | Updates Project type import to ~/insomnia-data. |
| packages/insomnia/src/routes/organization.$organizationId.project.$projectId.workspace.update.tsx | Uses services.project.getById and models.project.isGitProject. |
| packages/insomnia/src/routes/organization.$organizationId.project.$projectId.workspace.new.tsx | Uses services.project.getById and models.project.isGitProject/isLocalProject. |
| packages/insomnia/src/routes/organization.$organizationId.project.$projectId.workspace.move.tsx | Uses services.project.getById for target project when duplicating workspaces. |
| packages/insomnia/src/routes/organization.$organizationId.project.$projectId.workspace.delete.tsx | Uses services.project.getById and models.project.isRemoteProject. |
| packages/insomnia/src/routes/organization.$organizationId.project.$projectId.workspace.$workspaceId.tsx | Uses services.project.getById and models.project.isGitProject. |
| packages/insomnia/src/routes/organization.$organizationId.project.$projectId.workspace.$workspaceId.spec.tsx | Uses services.project.getById and models.project.isGitProject for repo selection. |
| packages/insomnia/src/routes/organization.$organizationId.project.$projectId.workspace.$workspaceId.spec.generate-request-collection.tsx | Uses services.project.getById and models.project.isGitProject for ruleset selection. |
| packages/insomnia/src/routes/organization.$organizationId.project.$projectId.workspace.$workspaceId.mock-server.tsx | Uses services.project.getById. |
| packages/insomnia/src/routes/organization.$organizationId.project.$projectId.workspace.$workspaceId.mock-server.generate-request-collection.tsx | Uses services.project.getById. |
| packages/insomnia/src/routes/organization.$organizationId.project.$projectId.workspace.$workspaceId.mcp.tsx | Uses services.project.getById. |
| packages/insomnia/src/routes/organization.$organizationId.project.$projectId.workspace.$workspaceId.insomnia-sync.tsx | Uses services.project.getById to validate remote project. |
| packages/insomnia/src/routes/organization.$organizationId.project.$projectId.workspace.$workspaceId.insomnia-sync.sync-data.tsx | Uses services.project.getById in loader/action. |
| packages/insomnia/src/routes/organization.$organizationId.project.$projectId.workspace.$workspaceId.insomnia-sync.push.tsx | Uses services.project.getById instead of legacy model. |
| packages/insomnia/src/routes/organization.$organizationId.project.$projectId.workspace.$workspaceId.insomnia-sync.pull.tsx | Uses services.project.getById instead of legacy model. |
| packages/insomnia/src/routes/organization.$organizationId.project.$projectId.workspace.$workspaceId.insomnia-sync.fetch.tsx | Uses services.project.getById instead of legacy model. |
| packages/insomnia/src/routes/organization.$organizationId.project.$projectId.workspace.$workspaceId.insomnia-sync.create-snapshot.tsx | Uses services.project.getById before optional push. |
| packages/insomnia/src/routes/organization.$organizationId.project.$projectId.workspace.$workspaceId.environment.tsx | Replaces isRemoteProject helper with models.project.isRemoteProject. |
| packages/insomnia/src/routes/organization.$organizationId.project.$projectId.workspace.$workspaceId.debug.tsx | Uses services.project.getById in loader. |
| packages/insomnia/src/routes/organization.$organizationId.project.$projectId.workspace.$workspaceId.debug.request.$requestId.grant-access.tsx | Uses services.project.getById/update for MCP access flag. |
| packages/insomnia/src/routes/organization.$organizationId.project.$projectId.update.tsx | Uses services.project.getById/update/remove and models.project.EMPTY_GIT_PROJECT_ID. |
| packages/insomnia/src/routes/organization.$organizationId.project.$projectId.tsx | Uses services.project.getById in loader. |
| packages/insomnia/src/routes/organization.$organizationId.project.$projectId.move.tsx | Uses services.project.getById/update when moving projects. |
| packages/insomnia/src/routes/organization.$organizationId.project.$projectId.move-workspace.tsx | Uses services.project.getById for validation. |
| packages/insomnia/src/routes/organization.$organizationId.project.$projectId.list-workspaces.tsx | Uses services.project.getById and Project type from ~/insomnia-data. |
| packages/insomnia/src/routes/organization.$organizationId.project.$projectId.delete.tsx | Uses services.project.getById/remove. |
| packages/insomnia/src/routes/organization.$organizationId.project.$projectId._index.tsx | Uses services.project.getById and models.project.* predicates for UI state. |
| packages/insomnia/src/routes/organization.$organizationId.insomnia-sync.pull-remote-file.tsx | Uses services.project.getByRemoteId. |
| packages/insomnia/src/routes/import.resources.tsx | Uses services.project.getById and models.project.isRemoteProject. |
| packages/insomnia/src/routes/git.all-connected-repos.tsx | Uses models.project.isEmptyGitProject (via models barrel) and Project type from ~/insomnia-data. |
| packages/insomnia/src/routes/git-credentials.$id.related-projects.tsx | Uses services.project.getAllByGitRepositoryIds. |
| packages/insomnia/src/routes/commands.tsx | Uses Project type from ~/insomnia-data for DB queries. |
| packages/insomnia/src/routes/auth.login.tsx | Uses models.project.SCRATCHPAD_PROJECT_ID. |
| packages/insomnia/src/network/network.ts | Uses models.project.isProject when building request location path. |
| packages/insomnia/src/network/tests/network.test.ts | Replaces models.project.all() with services.project.all(). |
| packages/insomnia/src/models/workspace.ts | Uses models.project.isProjectId from ~/insomnia-data. |
| packages/insomnia/src/models/stats.ts | Updates Project type import to ~/insomnia-data. |
| packages/insomnia/src/models/project.ts | Deletes legacy Project model implementation. |
| packages/insomnia/src/models/index.ts | Re-exports project as models.project from ~/insomnia-data. |
| packages/insomnia/src/models/helpers/project.ts | Uses services.project.update and models.project.isDefaultOrganizationProject. |
| packages/insomnia/src/models/environment.ts | Uses models.project.type from ~/insomnia-data for project queries. |
| packages/insomnia/src/models/tests/request.test.ts | Switches project setup to services.project.*. |
| packages/insomnia/src/main/git-service.ts | Uses services.project.* and models.project.EMPTY_GIT_PROJECT_ID/isEmptyGitProject. |
| packages/insomnia/src/insomnia-data/src/services/project.ts | Adds project storage-type helper functions under insomnia-data exports. |
| packages/insomnia/src/insomnia-data/src/models/types.ts | Re-exports Project/LocalProject/RemoteProject/GitProject types. |
| packages/insomnia/src/insomnia-data/src/models/project.ts | Adds Project model metadata/constants/type-guards in insomnia-data. |
| packages/insomnia/src/insomnia-data/src/models/index.ts | Adds project to insomnia-data model registry. |
| packages/insomnia/src/insomnia-data/src/index.ts | Re-exports the new project helpers from insomnia-data. |
| packages/insomnia/src/insomnia-data/node-src/services/project.ts | Adds IPC-friendly Project CRUD service implementation. |
| packages/insomnia/src/insomnia-data/node-src/services/index.ts | Registers project service in servicesNodeImpl. |
| packages/insomnia/src/insomnia-data/node-src/database/database.test.ts | Switches project creation in tests to services.project.create. |
| packages/insomnia/src/entry.main.ts | Initializes scratchpad project via services.project.* and models.project.SCRATCHPAD_PROJECT_ID. |
| packages/insomnia/src/common/render.ts | Uses models.project.isProject predicate from the models barrel. |
| packages/insomnia/src/common/import.ts | Uses services.project.getById and models.project.isGitProject. |
| packages/insomnia/src/common/tests/render.test.ts | Replaces models.project.all() with services.project.all(). |
| packages/insomnia/src/common/tests/insomnia-v5.test.ts | Switches project setup to services.project.create. |
| packages/insomnia/src/common/tests/import.test.ts | Switches project setup to services.project.create. |
| packages/insomnia/src/common/tests/har.test.ts | Replaces models.project.all() with services.project.all(). |
| packages/insomnia/src/account/session.ts | Uses services.project.update and project.EMPTY_GIT_PROJECT_ID from model metadata. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| import React, { type FC, Fragment, useEffect, useState } from 'react'; | ||
| import { Button, Menu, MenuItem, MenuTrigger, Popover, Tooltip, TooltipTrigger } from 'react-aria-components'; | ||
|
|
||
| import { getProjectStorageTypeLabel, models,type Project } from '~/insomnia-data'; |
There was a problem hiding this comment.
The import list is missing a space after the comma (models,type Project). This will fail formatting/linting (and is inconsistent with other imports in the repo).
| const newProject = (await services.project.getById(newProjectId)) as Project; | ||
| const workspaceExport = await getInsomniaV5DataExport({ |
There was a problem hiding this comment.
services.project.getById() can return null, but the result is force-cast to Project and used immediately. This can cause a runtime crash if the projectId is invalid or the project was deleted; add an invariant/null-check and return a user-friendly error instead of casting.
Migrate project model into insomnia-data
INS-2205