Skip to content

Commit bd303d7

Browse files
prabalpjoehan
andauthored
Ensure default service account is correctly set for Genkit monitoring IAM bindings:Fixes issue where an empty string could result in malformed IAM member serviceAccount: by properly checking index and replacing with the default service account. (#8760)
Co-authored-by: joehan <[email protected]>
1 parent 6dd4a51 commit bd303d7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/deploy/functions/checkIam.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,11 +206,11 @@ export async function ensureGenkitMonitoringRoles(
206206
.map((endpoint) => endpoint.serviceAccount || "")
207207
.filter((value, index, self) => self.indexOf(value) === index);
208208
const defaultServiceAccountIndex = serviceAccounts.indexOf("");
209-
if (defaultServiceAccountIndex) {
209+
if (defaultServiceAccountIndex !== -1) {
210210
serviceAccounts[defaultServiceAccountIndex] = await gce.getDefaultServiceAccount(projectNumber);
211211
}
212212

213-
const members = serviceAccounts.map((sa) => `serviceAccount:${sa}`);
213+
const members = serviceAccounts.filter((sa) => !!sa).map((sa) => `serviceAccount:${sa}`);
214214
const requiredBindings: iam.Binding[] = [];
215215
for (const monitoringRole of GENKIT_MONITORING_ROLES) {
216216
requiredBindings.push({

0 commit comments

Comments
 (0)