Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restconf server does NOT support multiple key requests on list nodes. #66

Open
Pawel-Guzik opened this issue Oct 3, 2024 · 0 comments

Comments

@Pawel-Guzik
Copy link

Pawel-Guzik commented Oct 3, 2024

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

  1. Start restconf server - go run main.go
  2. Create more than 1 resource within the books Yang node (it is already done, by configuration within startup.json file)
  3. 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
)
@Pawel-Guzik Pawel-Guzik changed the title restconf server does NOT support multiple keys GET request, on list node. restconf server does NOT support multiple keys GET request on list nodes. Oct 3, 2024
@Pawel-Guzik Pawel-Guzik changed the title restconf server does NOT support multiple keys GET request on list nodes. Restconf server does NOT support multiple keys GET request on list nodes. Oct 3, 2024
@Pawel-Guzik Pawel-Guzik changed the title Restconf server does NOT support multiple keys GET request on list nodes. Restconf server does NOT support multiple keys request on list nodes. Oct 3, 2024
@Pawel-Guzik Pawel-Guzik changed the title Restconf server does NOT support multiple keys request on list nodes. Restconf server does NOT support multiple keys requests on list nodes. Oct 3, 2024
@Pawel-Guzik Pawel-Guzik changed the title Restconf server does NOT support multiple keys requests on list nodes. Restconf server does NOT support multiple key requests on list nodes. Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant