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

incorrect serialization of yang namespace #207

Closed
RimShao opened this issue May 22, 2021 · 13 comments
Closed

incorrect serialization of yang namespace #207

RimShao opened this issue May 22, 2021 · 13 comments
Assignees
Labels

Comments

@RimShao
Copy link

RimShao commented May 22, 2021

Hi
yang lsp generates faulty namespace in below use case, Please use attached yang files yangTransform.zip to reproduce this problem.

  
deviation /me3gpp:ManagedElement/gnbdu3gpp:GNBDUFunction/nrcelldu3gpp:NRCellDU/nrcelldu3gpp:attributes/nrcelldu3gpp:bWPRef {
    deviate add {
        must 're-match(., concat("ManagedElement=", ../../../../me3gpp:id,",GNBDUFunction=", ../../../gnbdu3gpp:id,",BWP=[^,]+"))' {
             error-message
             "Must refer to a BWP in the same GNBDUFunction as the NRCellDU.";
        }
       }
     }
 

output:

deviation /me3gpp:ManagedElement/gnbdu3gpp:GNBDUFunction/nrcelldu3gpp:NRCellDU/nrcelldu3gpp:attributes/nrcelldu3gpp:bWPRef {
        deviate add {
            must 're-match(., concat("ManagedElement=", ../../../../me3gpp:id,",GNBDUFunction=", ../../../gnbdu3gpp:me3gpp:id,",BWP=[^,]+"))' {
                error-message^M
            "Must refer to a BWP in the same GNBDUFunction as the NRCellDU.";
            }
        }
    }

output gnbdu3gpp:id is expected instead of gnbdu3gpp:me3gpp:id .

@RimShao RimShao changed the title failed serialization of yang namespace incorrect serialization of yang namespace May 24, 2021
@dhuebner dhuebner self-assigned this May 25, 2021
@dhuebner
Copy link
Member

@RimShao
Thanks for providing an example model!

Unfortunately I can't reproduce the problem, maybe it is because of an error in module _3gpp-nr-nrm-nrcelldu

    list NRCellDU {
      description "Represents the information of a cell known by DU.";
      reference "3GPP TS 28.541";
      key id;  // <-- error here: Couldn't resolve reference to Leaf 'id'.

Could you please double check and verify the problem present with models from zip?
If so, could you give me a hint on how to reproduce? In our test cases we load the model file as is and invoke the serialize with parsed module as input.

@dhuebner
Copy link
Member

@RimShao
Can reproduce it now. The problem was that we already have _3gpp-nr-nrm-gnbdufunction and some other in our test resources sub-folders, so the wrong one was loaded.

@dhuebner
Copy link
Member

Note: The problem was that at ../../../gnbdu3gpp:id two elements with name id are accessible me3gpp:id and gnbdu3gpp:id. super.getCrossReferenceNameFromScope from YangCrossReferenceSerializer returned the first best element me3gpp:id.
io.typefox.yang.resource.YangCrossReferenceSerializer.getCrossReferenceNameFromScope(EObject, CrossReference, EObject, IScope, Acceptor) tries to cut the first segment me3gpp: but it does so only if it matches the prefix (here gnbdu3gpp), otherwise it returns the full name me3gpp:id. That is later concatenated with existing prefix gnbdu3gpp which gives gnbdu3gpp:me3gpp:id which is even syntactically wrong. The fix is in CrossRef serializer, but could be fixed in e.g. SerializerScopeProvider

@RimShao
Copy link
Author

RimShao commented May 27, 2021

@dhuebner

Great that the problem is reproduced and root cause is found.

@dhuebner
Copy link
Member

@RimShao
Are you able to test your case with current nightly?

@RimShao
Copy link
Author

RimShao commented May 27, 2021

@dhuebner

Where is the night build you mentioned ? Thanks a lot.

@dhuebner
Copy link
Member

@RimShao
Maven snapshot should be deployed automatically, but I will double check that.
Here is the build:
https://github.com/theia-ide/yang-lsp/actions/runs/878685021

@dhuebner
Copy link
Member

@RimShao
yang-lsp 0.5.0-SNAPSHOT was published Wed May 26 2021 15:32:09 GMT+0200 (CEST)

@RimShao
Copy link
Author

RimShao commented May 28, 2021

@dhuebner

Thanks a lot. the problem is fixed now.

Will you publish official 0.5.0 instead of 0.5.0-snapshot ?

@dhuebner
Copy link
Member

@RimShao
@andreasjakobik
Maybe we can put some more fixes into 0.5.0 ?

if not, then maybe 0.4.1 would be a better version choice

@RimShao
Copy link
Author

RimShao commented May 28, 2021

seems 0.4.1 is better

@andreasjakobik
Copy link

@dhuebner Thanks for quick fix. Here is another serialization issue, but it can wait until 0.5.0 release: #209

@dhuebner
Copy link
Member

dhuebner commented Jun 1, 2021

released with v0.4.1

@dhuebner dhuebner closed this as completed Jun 1, 2021
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

3 participants