Side Note: Below bug report based on GET request, but this case also applies to DELETE
Actual behavior
In the case of the Yang node request with multiple key values, restconf server response contains only resource coupled with the first key.
- Considering the following request
GET .../<list_node>=<key_1>,<key_2>,...,<key_n>
- Server responds with:
{<key_1_resource_value>}
Expected behavior
In the case of the Yang node request with multiple key values, restconf server response contains all resources coupled with each requested key.
- Considering the following request
GET .../<list_node>=<key_1>,<key_2>,...,<key_n>
- Server responds with:
{<key_1_resource_value>, <key_2_resource_value>,...,<key_n_resource_value>}
Reproduction steps
Code used to reproduce the bug can be found in the section below
- Start restconf server -
go run main.go
- Create more than 1 resource within the
books Yang node (it is already done, by configuration within startup.json file)
- Perform read request, requesting more than 1 resource from the
books list-node
Request:
curl -X GET http://localhost:8080/restconf/data/library:books=0,1
Response:
{"book-id":0,"title":"Book nr 0"}
Code used to reproduce a bug
yang/library.yang
module library {
revision 2024-10-03;
list books {
key book-id;
leaf book-id {
description "unique id for book";
type int32;
}
leaf title {
description "title of the book";
type string;
}
}
}
main.go
package main
import (
"github.com/freeconf/restconf"
"github.com/freeconf/restconf/device"
"github.com/freeconf/yang/fc"
"github.com/freeconf/yang/nodeutil"
"github.com/freeconf/yang/source"
)
type Book struct {
BookId int
Title string
}
type Library struct {
Books []*Book
}
type Model struct {
Library *Library
}
func NewLibrary() *Library {
lib := &Library{
Books: []*Book{},
}
return lib
}
func main() {
fc.DebugLog(true)
ypath := source.Any(source.Path("yang"), restconf.InternalYPath)
d := device.New(ypath)
rootNode := &nodeutil.Node{Object: NewLibrary()}
d.Add("library", rootNode)
restconf.NewServer(d)
d.ApplyStartupConfigFile("./startup.json")
select {}
}
startup.json
{
"fc-restconf": {
"web": {
"port": ":8080"
}
},
"library": {
"books": [
{
"book-id": 0,
"title": "Book nr 0"
},
{
"book-id": 1,
"title": "Book nr 1"
}
]
}
}
Additional informations
Related RESTCONF rfc section - https://datatracker.ietf.org/doc/html/rfc8040#section-3.5.3
go.mod content:
module multiplekeys
go 1.23.0
require (
github.com/freeconf/restconf v0.0.0-20240627124255-9543e7933a6e // indirect
github.com/freeconf/yang v0.0.0-20240126135339-ef92ddeb9f99 // indirect
)
Side Note: Below bug report based on
GETrequest, but this case also applies toDELETEActual behavior
In the case of the Yang node request with multiple key values, restconf server response contains only resource coupled with the first key.
GET .../<list_node>=<key_1>,<key_2>,...,<key_n>{<key_1_resource_value>}Expected behavior
In the case of the Yang node request with multiple key values, restconf server response contains all resources coupled with each requested key.
GET .../<list_node>=<key_1>,<key_2>,...,<key_n>{<key_1_resource_value>, <key_2_resource_value>,...,<key_n_resource_value>}Reproduction steps
Code used to reproduce the bug can be found in the section below
go run main.gobooksYang node (it is already done, by configuration withinstartup.jsonfile)bookslist-nodeRequest:
curl -X GET http://localhost:8080/restconf/data/library:books=0,1Response:
{"book-id":0,"title":"Book nr 0"}Code used to reproduce a bug
yang/library.yangmain.gostartup.json{ "fc-restconf": { "web": { "port": ":8080" } }, "library": { "books": [ { "book-id": 0, "title": "Book nr 0" }, { "book-id": 1, "title": "Book nr 1" } ] } }Additional informations
Related RESTCONF rfc section - https://datatracker.ietf.org/doc/html/rfc8040#section-3.5.3
go.modcontent: