Closed CC-vga closed 2 months ago
Interesting, when Decoding a JSON blob for the same model, it all works fine.
The XML is valid, I get to encode the same text from the binding.
Could you try using JSON instead of XML, for now?
I was able to narrow this down to pyanbind trying to check the pattern restriction on an lxml.objectify.StringElement object, which is not a native string type. With JSON decoding, this problem does not happen because the JSON value is a native str type.
So in https://github.com/robshakir/pyangbind/tree/fix_xml_decode_regex_key I added a UnitTest and a fix for this.
Could you please try to use this Branch and let me know if this works for you. I will raise a PR after that.
Hi,
Thanks, I’ll take the branch suggested 😊 From what I saw, I need to strip of escaped ‘ the value of the string primary key.
All best
From: Jose Ignacio Tamayo Segarra @.> Sent: Wednesday, 13 March 2024 10:41 pm To: robshakir/pyangbind @.> Cc: Voica Gavrilut @.>; Author @.> Subject: Re: [robshakir/pyangbind] Primary key of a list cannot be of type string with a specific pattern (Issue #345)
[External]
I was able to narrow this down to pyanbind trying to check the pattern restriction on an lxml.objectify.StringElement object, which is not a native string type. With JSON decoding, this problem does not happen because the JSON value is a native str type.
So in https://github.com/robshakir/pyangbind/tree/fix_xml_decode_regex_key I added a UnitTest and a fix for this.
Could you please try to use this Branch and let me know if this works for you. I will raise a PR after that.
— Reply to this email directly, view it on GitHubhttps://github.com/robshakir/pyangbind/issues/345#issuecomment-1995912072, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AMLNYJUKDEC2RZEET4XIPTTYYDBWNAVCNFSM6AAAAABEK3Z5EGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOJVHEYTEMBXGI. You are receiving this because you authored the thread.Message ID: @.**@.>>
Hi again,
I’m sorry, I didn’t manage to install the package from the given branch!
Cheers
From: Jose Ignacio Tamayo Segarra @.> Sent: Wednesday, 13 March 2024 10:41 pm To: robshakir/pyangbind @.> Cc: Voica Gavrilut @.>; Author @.> Subject: Re: [robshakir/pyangbind] Primary key of a list cannot be of type string with a specific pattern (Issue #345)
[External]
I was able to narrow this down to pyanbind trying to check the pattern restriction on an lxml.objectify.StringElement object, which is not a native string type. With JSON decoding, this problem does not happen because the JSON value is a native str type.
So in https://github.com/robshakir/pyangbind/tree/fix_xml_decode_regex_key I added a UnitTest and a fix for this.
Could you please try to use this Branch and let me know if this works for you. I will raise a PR after that.
— Reply to this email directly, view it on GitHubhttps://github.com/robshakir/pyangbind/issues/345#issuecomment-1995912072, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AMLNYJUKDEC2RZEET4XIPTTYYDBWNAVCNFSM6AAAAABEK3Z5EGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOJVHEYTEMBXGI. You are receiving this because you authored the thread.Message ID: @.**@.>>
From what I saw, I need to strip of escaped ‘ the value of the string primary key.
What do you mean? By editing somethin on the XML? I tried scaping, and the issue I found is specifically to Decoding XML which produce a non-str type object.
I’m sorry, I didn’t manage to install the package from the given branch!
You need to git clone
locally the branch, instead of using the package from pip. Something like:
git clone git@github.com:robshakir/pyangbind.git
cd pyangbind
git checkout fix_xml_decode_regex_key
PYTHONPATH=. pyang --plugindir ./pyangbind/plugin -f pybind -o binding.py <hier your YANG file>
PYTHONPATH=. py # here do the decoding of your XML
Considering this fixed in https://github.com/robshakir/pyangbind/pull/346
I got an error when I decode an XML with valid value for an XML element. The XML element is declared as string with a given pattern in the yang model. And the 'valid' value matches the pattern. Here is an example of the YANG model, XML file and obtained error :)
Excerpt of the YANG model:
The whole YANG model is validated by pyang!
XML sample:
Error message:
Do you know any work-around for this problem? BTW, I'm using pyangbind version 0.8.5.
Thank you Voica