Skip to content

Commit

Permalink
prevent panic accesing services in extended file
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas De Loof <[email protected]>
  • Loading branch information
ndeloof committed Sep 9, 2024
1 parent 7b77fc9 commit 4f02e42
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions loader/extends.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,15 @@ func getExtendsBaseFromFile(
if err != nil {
return nil, nil, err
}
services := source["services"].(map[string]any)
_, ok := services[ref]
m, ok := source["services"]
if !ok {
return nil, nil, fmt.Errorf("cannot extend service %q in %s: no services section", name, local)
}
services, ok := m.(map[string]any)
if !ok {
return nil, nil, fmt.Errorf("cannot extend service %q in %s: services must be a mapping", name, local)
}
_, ok = services[ref]
if !ok {
return nil, nil, fmt.Errorf(
"cannot extend service %q in %s: service %q not found in %s",
Expand Down

0 comments on commit 4f02e42

Please sign in to comment.