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

Using YANG union with decimal64 and string leads to regexp match fail #226

Closed
paul-sirin opened this issue May 23, 2021 · 2 comments
Closed
Labels

Comments

@paul-sirin
Copy link

After we enabled state data XML validation we have an issue with YANG union that can hold either decimal64 or string with pattern. I was able to reproduce the issue on clixon example using following patch:

diff --git a/example/main/clixon-example@2020-12-01.yang b/example/main/clixon-example@2020-12-01.yang
index 412e571d..914340f9 100644
--- a/example/main/clixon-example@2020-12-01.yang
+++ b/example/main/clixon-example@2020-12-01.yang
@@ -64,7 +64,14 @@ module clixon-example {
          config false;
          description "state data for the example application (must be here for example get operation)";
          leaf-list op {
-            type string;
+            type union {
+              type decimal64{
+                fraction-digits 2;
+              }
+              type string{
+                pattern "N/A";
+              }
+            }
          }
     }
     augment "/if:interfaces/if:interface" {
diff --git a/example/main/example.xml b/example/main/example.xml
index 63272346..4cc945f9 100644
--- a/example/main/example.xml
+++ b/example/main/example.xml
@@ -21,4 +21,5 @@
   <CLICON_NACM_MODE>disabled</CLICON_NACM_MODE>
   <CLICON_STREAM_DISCOVERY_RFC5277>true</CLICON_STREAM_DISCOVERY_RFC5277>
   <CLICON_MODULE_LIBRARY_RFC7895>false</CLICON_MODULE_LIBRARY_RFC7895>
+  <CLICON_VALIDATE_STATE_XML>true</CLICON_VALIDATE_STATE_XML>
 </clixon-config>

When I try to run example with state data enabled the issue happens all time when XML validation is enabled:

user@tpg-lt /> show state
May 19 10:54:27: Get configuration: application operation-failed regexp match fail: pattern does not match 41. Internal error, state callback returned
invalid XML <bad-element>op</bad-element>
CLI command error
@olofhagsand
Copy link
Member

decimal64 fraction was not correctly read when validating a union.
Please verify

@paul-sirin
Copy link
Author

Thanks, it works well for both -- example and our code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants