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

JSON namespace-qualified names not supported #33

Closed
tdecorte123 opened this issue Dec 21, 2022 · 4 comments
Closed

JSON namespace-qualified names not supported #33

tdecorte123 opened this issue Dec 21, 2022 · 4 comments

Comments

@tdecorte123
Copy link

Hi, I'm experimenting with these nice libraries by writing a prototype restconf server for some custom yang models.

It works fine except when my querie contains namespace prefixes. Looking at the yang library, it seems that namespaces are not supported... Except for a compatibility mode used in the JSON writer but not when parsing JSON body queries.

Is this correct or am I missing something somewhere?

Thx

@dhubler
Copy link
Collaborator

dhubler commented Dec 22, 2022 via email

@tdecorte123
Copy link
Author

Hi, thx for the reply.

In a nutshell, I have an identityref leaf using a derived type defined in an imported yang module. When processing the leaf, this code:
func toIdentRef(base *meta.Identity, v interface{}) (val.IdentRef, error) {
var empty val.IdentRef
x := fmt.Sprintf("%v", v)
ref, found := base.Derived()[x]
//...
}

compares namespace-qualified name receive in the JSON with the derived type name without the namespace. In other words it compares A:B with B. Which fails. If I remove the namespace from the JSON body, it works fine.

I can provide a small example if needed.

Thx

@tdecorte123
Copy link
Author

tdecorte123 commented Dec 22, 2022

Hi,

A quick and dirty example that will panic at startup:

main.go.txt
Module-test.yang.txt
Module-types.yang.txt

If you remove the namespace ("type":"derived-type") it works... But when getting back the "type" leaf you get this result:
GET http://localhost:8090/restconf/data/Module-test
{
"Module-test:type": "derived-type"
}

Here the namespace is applied to the key and not the value which is incorrect as far as I know. type doesn't require a namspace since it's already in Module-test namespace and the derived type needs to be prefixed.

As a reference, section 6.8 of RFC7951.

Thx

@dhubler
Copy link
Collaborator

dhubler commented Dec 27, 2022

I was able to duplicate this and spec reference confirms your assertion. I should have fix and unit test in next couple days, thanks for reporting!

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

2 participants