[YANGTOOLS-1495] Deviation must not target the same module as the one it is defined in Created: 17/Mar/23  Updated: 20/Mar/23

Status: Open
Project: yangtools
Component/s: parser
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Medium
Reporter: Xiao Jing Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Hi,

This is more like a query.

Recently we found some yang files from our product team are failing the ODL parser. And the error is "Deviation must not target the same module as the one it is defined in".

The root cause is obvious - they put some deviations in the same module they target.

But the validators they are using do not report this kind of error.

So we would like to know why ODL has this restriction? Is there any reference in RFC?

The exception is thrown in yangtools/yang/parser/rfc7950/stmt/meta/DeviationStatementSupport.java

        final var targetModule = Iterables.getLast(ctx.getArgument().getNodeIdentifiers()).getModule();
        if (currentModule.equals(targetModule)) {
            throw new InferenceException(ctx,
                    "Deviation must not target the same module as the one it is defined in: %s", currentModule);
        }

 

Really appreciate your help. 



 Comments   
Comment by Robert Varga [ 17/Mar/23 ]

This goes back to YANGTOOLS-638, not sure where exactly we picked it up. At the end of the day, there are three pieces to this:

Comment by Xiao Jing [ 20/Mar/23 ]

rovarga Thanks a lot for your reply! Will share the info and trigger more discussions.

Comment by Xiao Jing [ 20/Mar/23 ]

Hi rovarga 

We just have a discussion with our Yang Model expert Balázs Lengyel here.

I would quote:

Neither https://www.rfc-editor.org/rfc/rfc8407.html#section-4.2 nor https://www.rfc-editor.org/rfc/rfc6020#section-5.6.4.3 says that deviation statements and their target MUST be in different files, thus it is allowed.

Also in this case the deviation statement references a target defined in a grouping statement in another module that is only used via a "uses groupingName" statement.  So even if deviating the same module would be forbidden, this is not the case, so it should allow this.

So can we improve ODL in this case?

Thanks

Generated at Wed Feb 07 20:56:19 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.