Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ All notable changes to the Docker Language Server will be documented in this fil
- Compose
- textDocument/completion
- fix error case triggered by using code completion before the first node ([#314](https://github.com/docker/docker-language-server/issues/314))
- textDocument/definition
- check the type of a dependency node's value before assuming it is a map and recursing into it ([#324](https://github.com/docker/docker-language-server/issues/324))
- textDocument/hover
- protect the processing of included files if the node is not a proper array ([#322](https://github.com/docker/docker-language-server/issues/322))
- Bake
Expand Down
8 changes: 5 additions & 3 deletions internal/compose/definition.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,11 @@ func dependencyLookup(doc document.ComposeDocument, dependencyType, name string)
if mappingNode, ok := doc.Body.(*ast.MappingNode); ok {
for _, node := range mappingNode.Values {
if s, ok := node.Key.(*ast.StringNode); ok && s.Value == dependencyType {
for _, service := range node.Value.(*ast.MappingNode).Values {
if s, ok := service.Key.(*ast.StringNode); ok && s.Value == name {
return service, u
if m, ok := node.Value.(*ast.MappingNode); ok {
for _, service := range m.Values {
if s, ok := service.Key.(*ast.StringNode); ok && s.Value == name {
return service, u
}
}
}
}
Expand Down
16 changes: 16 additions & 0 deletions internal/compose/definition_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,22 @@ services:
},
},
},
{
name: "dependent file is not defined properly",
content: `
include:
- compose.other.yaml
services:
test:
networks:
- other`,
otherContent: `
networks: string`,
line: 6,
character: 11,
locations: nil,
links: nil,
},
}

for _, tc := range testCases {
Expand Down
Loading