Skip to content

Conversation

@rickary
Copy link
Contributor

@rickary rickary commented Jun 2, 2025

Note: branched off #29 as how that works directly affects this feature

@rickary rickary linked an issue Jun 2, 2025 that may be closed by this pull request
@rickary rickary force-pushed the 26-support-multiple-projects branch from a5d556e to e811f7a Compare June 10, 2025 09:47
@rickary rickary marked this pull request as ready for review June 13, 2025 08:45
@rickary rickary changed the base branch from main to 30-request-parameter-issue June 13, 2025 08:54
@rickary rickary requested a review from riceyrice June 13, 2025 09:20
Copy link
Contributor

@riceyrice riceyrice left a comment

Choose a reason for hiding this comment

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

LGTM. Very happy to see this fixed!

@rickary rickary force-pushed the 26-support-multiple-projects branch 2 times, most recently from cacdeda to 11a0f72 Compare June 16, 2025 09:58
@rickary rickary requested a review from riceyrice June 16, 2025 10:02
Base automatically changed from 30-request-parameter-issue to main June 16, 2025 15:04
wip

rm some logs

working

loading indicator works correctly

project setting

self cr

cr

rebase

project name
@rickary rickary force-pushed the 26-support-multiple-projects branch from 11a0f72 to 8f9fc26 Compare June 17, 2025 12:49
Copy link
Contributor

@riceyrice riceyrice left a comment

Choose a reason for hiding this comment

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

noice

@rickary rickary requested a review from matthewelwell June 17, 2025 12:59
@matthewelwell matthewelwell requested a review from Zaimwa9 June 17, 2025 13:03
Copy link
Contributor

@Zaimwa9 Zaimwa9 left a comment

Choose a reason for hiding this comment

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

Thanks! Tested and working as expected 👍 . One concern over the amount of requests we are doing and one minor comment


const allFeatures: Feature[] = [];
const organisationId = await readOrganisationId();
const projects = await readProjects({ organisationId });
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm a bit concerned here by the amount of requests we are doing.

Basically here we map over the environments

          return await Promise.all(
            environments.map((environment) =>
              readFeatures({ projectIds, environmentId: String(environment.id) }),

And making this request for each of them to later do a find.

The projects shouldn't change from one request to another so could we find a way to request once and re-use the result directly ? Maybe having the projects as an argument directly ?

@rickary rickary requested a review from Zaimwa9 June 20, 2025 10:46
Copy link
Contributor

@riceyrice riceyrice left a comment

Choose a reason for hiding this comment

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

I'm not sure this most recent change is the right way to address the concern!


const allFeatures: Feature[] = [];
const organisationId = await readOrganisationId();
const projects = await readProjects({ organisationId });
Copy link
Contributor

Choose a reason for hiding this comment

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

There is a trust issue here. The client-side is untrustworthy, so a Jira user with the correct IDs can potentially retrieve data for projects that are available to the API key even if they are not connected to the Flagsmith organisation that the Jira instance is associated with.

This is why the all the backend Flagsmith API calls retrieve the organisation ID from the Jira instance and then the projects for that organisation from the Flagsmith API and then use this to filter any project IDs provided by the client. The trade-off is that makes more API calls than is ideal.

Having the client-side provide the project list bypasses this check, so I don't think this is a good idea.

The correct fix is to use organisation-scoped (RBAC) API keys, which I think is the next scheduled work item? When an RBAC API key is in use, there is no need for the backend to retrieve projects for filtering as any API call to a project ID that isn't permitted will cause an auth error.

This particular backend function also uses the project list to annotate the features with the project name as a convenience but this could be done on the client-side with the backend annotating with the project ID instead.

If API loading is a genuine issue in the interim then adding some jitter to the calls in the backend could help?

Copy link
Contributor

@Zaimwa9 Zaimwa9 Jun 20, 2025

Choose a reason for hiding this comment

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

Ok thanks for the detailed answer @riceyrice 🙏 .

I was unaware that RBAC was an incoming item.
In that case it make sense to keep the security over efficiency trade-off for now. The traffic is acceptable at the moment. But can we add a comment to keep under the radar the improvement and properly fix it once RBAC is tackled

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Zaimwa9 I've reverted the changes relating to the making multiple requests and added a comment linking to the github issue.

@rickary rickary force-pushed the 26-support-multiple-projects branch from 383f596 to bae9697 Compare June 26, 2025 07:53
Copy link
Contributor

@Zaimwa9 Zaimwa9 left a comment

Choose a reason for hiding this comment

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

Thanks a lot, looks good to me. Will test it again and merge

@Zaimwa9 Zaimwa9 merged commit 5122006 into main Jun 26, 2025
1 check 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.

Add support for multiple projects

4 participants