Skip to content

Commit

Permalink
Lock state access in builtinProvider.getResource (#16225)
Browse files Browse the repository at this point in the history
<!--- 
Thanks so much for your contribution! If this is your first time
contributing, please ensure that you have read the
[CONTRIBUTING](https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md)
documentation.
-->

# Description

<!--- Please include a summary of the change and which issue is fixed.
Please also include relevant motivation and context. -->

Found by data race checker.
  • Loading branch information
Frassle committed May 18, 2024
1 parent 6dfd57d commit 5de4c2a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/resource/deploy/builtins.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,10 @@ func (p *builtinProvider) getResource(inputs resource.PropertyMap) (resource.Pro
return nil, fmt.Errorf("unknown resource %v", urn.StringValue())
}

// Take the state lock so we can safely read the Outputs.
state.Lock.Lock()
defer state.Lock.Unlock()

return resource.PropertyMap{
"urn": urn,
"id": resource.NewStringProperty(string(state.ID)),
Expand Down

0 comments on commit 5de4c2a

Please sign in to comment.