Skip to content

Commit 9551d61

Browse files
Fix an unsafe type assertion in google_artifact_registry_repository (#13445) (#22100)
[upstream:dcc854f0bbe247a66a02a3b4a300b7a3473e1f3b] Signed-off-by: Modular Magician <[email protected]>
1 parent 3875936 commit 9551d61

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

.changelog/13445.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note: bug
2+
artifactregistry: fixed type assertion panic `google_artifact_registry_repository`
3+
```

google/services/artifactregistry/resource_artifact_registry_repository.go

+9-2
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,15 @@ func durationDiffSuppress(k, oldr, newr string, d *schema.ResourceData) bool {
118118
}
119119

120120
func mapHashID(v any) int {
121-
obj := v.(map[string]any)
122-
return schema.HashString(obj["id"])
121+
obj, ok := v.(map[string]any)
122+
if !ok {
123+
return 0
124+
}
125+
s, ok := obj["id"].(string)
126+
if !ok {
127+
return 0
128+
}
129+
return schema.HashString(s)
123130
}
124131

125132
func isDefaultEnum(val any) bool {

0 commit comments

Comments
 (0)