fix: handle team deletion gracefully in permission resources #559
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fixed TeamStackPermission and TeamEnvironmentPermission resources to gracefully handle scenarios where teams are deleted externally (via SCIM/SSO) by treating 404 responses as resource deletions rather than fatal errors.
Problem
Organizations using SCIM/SSO for team management encountered unrecoverable failures when external identity providers deleted or renamed teams:
pulumi refreshandpulumi upfailed with "404 API error: Not Found: Team not found"pulumi state deletefor potentially hundreds of permission resourcesChanges
API Client Layer (
provider/pkg/pulumiapi/teams.go)(nil, nil)when team doesn't exist (lines 377-381)(nil, nil, nil)when team doesn't exist (lines 466-470)GetTeam()method which already handled 404s gracefullyResource Layer (
provider/pkg/resources/team_stack_perm.go)DeleteBeforeReplace: trueflag (line 152) to prevent race conditions during replace operationsTesting (
provider/pkg/pulumiapi/teams_test.go)TestGetTeamStackPermission/404_-_Team_not_found(lines 422-436)TestGetTeamEnvironmentSettings/404_-_Team_not_found(lines 523-543)Testing Done
✅ All 100+ provider tests pass
✅ New unit tests verify 404 handling behavior
✅ Linting passes across provider, sdk, and examples directories ✅ Resource
Read()methods already handle nil responses correctly (verified in existing code)Impact
pulumi refreshnow succeeds when teams are deleted externally, removing permissions from stateFixes #444