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 PATCH method request failed on item defined by submodule #306

Closed
zaker139 opened this issue Feb 21, 2022 · 2 comments
Closed

Restconf PATCH method request failed on item defined by submodule #306

zaker139 opened this issue Feb 21, 2022 · 2 comments

Comments

@zaker139
Copy link

Consider YANG models below:
test.yang

module test {
    yang-version 1.1;
    namespace "http://www.test.com/test";
    prefix test;

    include test-augment;

    container con {
        leaf a {
            type string;
        }
    }    
}

test-augment.yang

submodule test-augment {

    belongs-to "test" {
        prefix "test";
    }

    augment "/test:con" {
        leaf b {
            type string;
        }
    }
}

Using restconf PATCH /test:con/a success.

curl -X PATCH -H "Content-Type: application/yang-data+json" -d '{
    "test:a": "hello123"
}' http://localhost/restconf/data/test:con/a

Whereas same request on /test:con/b would failed with error below:

curl -X PATCH -H "Content-Type: application/yang-data+json" -d '{
    "test:b": "hello13434"
}' http://localhost/restconf/data/test:con/b
{
"ietf-restconf:errors" : {
  "error": {
    "error-type": "rpc",
    "error-tag": "malformed-message",
    "error-severity": "error",
    "error-message": "Data is not prefixed with matching namespace"
  }
}

}

Seems in restconf_methods.c:372, ymoddata and ymodapi are not the samething.

if (ymoddata && ymodapi){

ymodapi points to a submodule yang_stmt, but ymoddata points to a main module.

@olofhagsand
Copy link
Member

Thanks for detecting this important cornercase error.
Please verify the submitted fix.

@zaker139
Copy link
Author

zaker139 commented Mar 2, 2022

Issue fixed

@zaker139 zaker139 closed this as completed Mar 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants