-
Notifications
You must be signed in to change notification settings - Fork 1.6k
feat(cli): allow using project name to resolve project ID (#2594) #4857
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat(cli): allow using project name to resolve project ID (#2594) #4857
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Greptile OverviewGreptile SummaryAdded new Critical Issue Found:
Additional Observations:
Confidence Score: 1/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant Caller
participant getProjectByName
participant projectDAL
participant permissionService
Caller->>getProjectByName: name, actor, actorId, actorOrgId, actorAuthMethod
getProjectByName->>projectDAL: findOne({ name, orgId })
alt Project not found
projectDAL-->>getProjectByName: null
getProjectByName-->>Caller: throw NotFoundError
else Project found
projectDAL-->>getProjectByName: project
getProjectByName->>permissionService: getProjectPermission(actor, actorId, projectId, etc)
permissionService-->>getProjectByName: { permission }
alt Lacks Read permission
getProjectByName-->>Caller: throw ForbiddenError
else Has Read permission
getProjectByName-->>Caller: return project
end
end
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 file reviewed, 1 comment
| actorOrgId: string; | ||
| actorAuthMethod: ActorAuthMethod; | ||
| }) => { | ||
| const project = await projectDAL.findOne({ name, orgId: actorOrgId }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: project names are not unique within an org - multiple projects can share the same name. Using findOne with just name and orgId may return an arbitrary project if duplicates exist, potentially granting access to the wrong project. This is a critical security issue.
Verify project name uniqueness constraints in schema, or use slug instead (which is unique).
Summary
Introduced a new
getProjectByNameservice method inprojectServiceFactoryto retrieve a project by its name.Motivation
Currently, projects can only be retrieved using their ID or slug. This change adds the ability to fetch projects by their name while maintaining consistent permission checks and error handling.
Implementation Details
getProjectByNamemethod inproject-service.tspermissionService.getProjectPermissionto enforce access controlNotFoundErrorwhen the project name does not existForbiddenErrorwhen the user lacks project read permissionsImpact
This improvement enhances developer experience when integrating APIs that rely on project names instead of IDs, making the API more flexible.
✅ Tested locally
✅ Follows existing service structure and permission model
✅ Non-breaking enhancement