Skip to content

inlined.sa propagation cleanup - #10871

Merged
inlined merged 10 commits into
mainfrom
inlined.sa-propagation-cleanup
Jul 30, 2026
Merged

inlined.sa propagation cleanup#10871
inlined merged 10 commits into
mainfrom
inlined.sa-propagation-cleanup

Conversation

@inlined

@inlined inlined commented Jul 30, 2026

Copy link
Copy Markdown
Member

Fixes #10859 and #10860

To handle race conditions with SA propagation without polluting code everywhere, executor and throttler queue now accept retry predicates. Friendly predicate names are provided. I've opted to not have consts that are used repeatedly because isTransientError seems like a good thing to be able to read at the call site for what is retried.

To handle cleanup we've just extended the logic in fabricator.

Comment thread src/deploy/functions/release/executor.ts Fixed

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request adds the FUNCTION_REGION environment variable to v2 functions to maintain parity with v1 behavior. It also refactors the deployment retry mechanism to use flexible RetryPredicate functions instead of numeric codes, enabling retries on specific 404 errors related to service accounts. Additionally, it introduces automatic cleanup of newly created service accounts on 100% deployment or role assignment failures. The feedback highlights a potential crash in the isServiceAccount404 predicate when calling JSON.stringify(err) on circular error structures, suggesting a safer try-catch fallback to String(err).

Comment thread src/deploy/functions/release/executor.ts
inlined added a commit that referenced this pull request Jul 30, 2026
### Description
Updates CHANGELOG.md to reference PR #10871. Refactors isServiceAccount404 in executor.ts to safely extract error text with String(err) fallback inside a try-catch block to prevent circular reference stringification errors.

### Scenarios Tested
- Run mocha unit tests
- Run npm run format
Comment thread src/deploy/functions/release/executor.ts Fixed
inlined added 3 commits July 30, 2026 13:26
Fixes service account IAM propagation delays during Cloud Functions creation by adding a pluggable retry policy to executor task runs. Automatically deletes newly created managed service accounts if 100% of function deploys fail for a codebase.

Fixes #10859
Fixes #10860

- Run unit tests: npx mocha src/deploy/functions/release/executor.spec.ts src/deploy/functions/release/fabricator.spec.ts src/deploy/functions/release/planner.spec.ts src/deploy/functions/prepare.spec.ts
- Verified lint: npm run lint:changed-files

N/A
Updates CHANGELOG.md to reference PR #10871. Refactors isServiceAccount404 in executor.ts to safely extract error text with String(err) fallback inside a try-catch block to prevent circular reference stringification errors.

- Run mocha unit tests
- Run npm run format
…ecutor

### Description
Replaces unanchored substring search with word boundary regex checks in isServiceAccount404 to resolve CodeQL alert.

### Scenarios Tested
- Run mocha tests
- Verified formatting
@inlined
inlined force-pushed the inlined.sa-propagation-cleanup branch from 5636c69 to c1bf446 Compare July 30, 2026 20:36
@inlined

inlined commented Jul 30, 2026

Copy link
Copy Markdown
Member Author

Note: The change to GEMINI.md is because it failed to follow the rule. When interrogated it said that's because it interpreted the rule to be about functions, not loops and suggested the change.

@inlined

inlined commented Jul 30, 2026

Copy link
Copy Markdown
Member Author

Also, ignore the function region stuff; that was a bad diffbase

Comment thread src/deploy/functions/release/executor.ts Outdated
inlined and others added 2 commits July 30, 2026 15:48
…ount404

### Description
Concatenates err.message, err.original?.message, err.context?.body?.error?.message, and String(err) in isServiceAccount404 instead of short-circuiting via || to ensure nested error details are inspected.

### Scenarios Tested
- Run mocha unit tests
@inlined
inlined enabled auto-merge (squash) July 30, 2026 22:58
@inlined
inlined merged commit 25857a2 into main Jul 30, 2026
52 of 53 checks passed
@inlined
inlined deleted the inlined.sa-propagation-cleanup branch July 30, 2026 23:10
tagboola pushed a commit that referenced this pull request Aug 5, 2026
* fix(functions): retry SA 404s and clean up SA on 100% deployment failure

Fixes service account IAM propagation delays during Cloud Functions creation by adding a pluggable retry policy to executor task runs. Automatically deletes newly created managed service accounts if 100% of function deploys fail for a codebase.

Fixes #10859
Fixes #10860

- Run unit tests: npx mocha src/deploy/functions/release/executor.spec.ts src/deploy/functions/release/fabricator.spec.ts src/deploy/functions/release/planner.spec.ts src/deploy/functions/prepare.spec.ts
- Verified lint: npm run lint:changed-files

N/A

* fix(functions): address PR review comments for SA propagation retries

Updates CHANGELOG.md to reference PR #10871. Refactors isServiceAccount404 in executor.ts to safely extract error text with String(err) fallback inside a try-catch block to prevent circular reference stringification errors.

- Run mocha unit tests
- Run npm run format

* fix(functions): use word boundary regex for gserviceaccount.com in executor

### Description
Replaces unanchored substring search with word boundary regex checks in isServiceAccount404 to resolve CodeQL alert.

### Scenarios Tested
- Run mocha tests
- Verified formatting

* style(functions): format long string in executor.spec.ts to satisfy prettier

* style(changelog): format CHANGELOG.md with prettier

* style(changelog): reset CHANGELOG.md to single PR entry following release

* style(changelog): prettier format single entry CHANGELOG.md

* fix(functions): concatenate all error message sources in isServiceAccount404

### Description
Concatenates err.message, err.original?.message, err.context?.body?.error?.message, and String(err) in isServiceAccount404 instead of short-circuiting via || to ensure nested error details are inspected.

### Scenarios Tested
- Run mocha unit tests
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.

Declarative security: first deploy with a fresh managed SA fails with 404 actAs (no propagation wait or retry)

5 participants