File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -132,8 +132,8 @@ export class PostHogAPIClient {
132132 }
133133 }
134134
135- setTeamId ( teamId : number ) : void {
136- this . _teamId = teamId ;
135+ setTeamId ( teamId : number | null | undefined ) : void {
136+ this . _teamId = teamId ?? null ;
137137 }
138138
139139 private async getTeamId ( ) : Promise < number > {
Original file line number Diff line number Diff line change @@ -195,7 +195,10 @@ async function buildOrgProjectsMap(
195195
196196 const entries = await Promise . all (
197197 orgs . map ( async ( org ) => {
198- const projects = await client . listOrgProjects ( org . id ) . catch ( ( ) => [ ] ) ;
198+ const projects = await client . listOrgProjects ( org . id ) . catch ( ( err ) => {
199+ log . warn ( "Failed to fetch projects for org" , { orgId : org . id , err } ) ;
200+ return [ ] ;
201+ } ) ;
199202 return [
200203 org . id ,
201204 {
@@ -814,6 +817,14 @@ export const useAuthStore = create<AuthState>()(
814817 selectProject : ( projectId : number ) => {
815818 const state = get ( ) ;
816819
820+ const allProjectIds = Object . values ( state . orgProjectsMap ) . flatMap (
821+ ( o ) => o . projects . map ( ( p ) => p . id ) ,
822+ ) ;
823+ if ( ! allProjectIds . includes ( projectId ) ) {
824+ log . error ( "Attempted to select invalid project" , { projectId } ) ;
825+ throw new Error ( "Invalid project selection" ) ;
826+ }
827+
817828 const cloudRegion = state . cloudRegion ;
818829 if ( ! cloudRegion ) {
819830 throw new Error ( "No cloud region available" ) ;
Original file line number Diff line number Diff line change @@ -69,6 +69,5 @@ export function useProjects() {
6969 currentProject,
7070 currentProjectId,
7171 isLoading : false ,
72- error : null ,
7372 } ;
7473}
You can’t perform that action at this time.
0 commit comments