[YANGTOOLS-537] Yang parsing succeeds with missing '}' in leaf Created: 27/Oct/15  Updated: 10/Apr/22  Resolved: 31/Oct/15

Status: Resolved
Project: yangtools
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug
Reporter: Tom Pantelis Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: All
Platform: All


Issue Links:
Blocks
blocks INTDIST-42 config-pusher error in messaging4tran... Resolved
External issue ID: 4539

 Description   

If you omit the ending '}' for a leaf statement, parsing succeeds and code is generated, or at least some of it as in some cases Java compilation may fail.

Example: in the mdsal project, go to mdsal/model/ietf/ietf-restconf and do mvn clean. Open src/main/yang/ietf-restconf@2013-10-19.yang. On line 189, remove the ending '}':

leaf edit-id

{ type string; description "Arbitrary string index for the edit. Error messages returned by the server pertaining to a specific edit will be identified by this value."; }

--> line 189

Run mvn and you should see yang parsing succeed and files generated but a Java compilation error.



 Comments   
Comment by Robert Varga [ 28/Oct/15 ]

There is also a report of the following:

2)
opendaylight-user@root>feature:install odl-integration-compatible-with-all
line 93:0 extraneous input '}' expecting

{<EOF>, SEP}
line 124:13 extraneous input ',' expecting {'}', SEP, IDENTIFIER}
line 93:0 extraneous input '}' expecting {<EOF>, SEP}

line 124:13 extraneous input ',' expecting

{'}', SEP, IDENTIFIER}
opendaylight-user@root>line 124:13 extraneous input ',' expecting {'}

', SEP, IDENTIFIER}

Which seems to be related.

Comment by Tom Pantelis [ 28/Oct/15 ]

With the old parser you get:

[ERROR] Failed to execute goal org.opendaylight.yangtools:yang-maven-plugin:0.7.2-SNAPSHOT:generate-sources (default) on project ietf-restconf: yang-to-sources: Unable to parse yang files from /home/mininet/ODL/lithium/yangtools/model/ietf/ietf-restconf/src/main/yang: Failed to parse yang data: extraneous input 'leaf' expecting

{'}

', 'when', 'units', 'type', 'status', 'reference', 'must', 'mandatory', 'if-feature', 'description', 'default', 'config', IDENTIFIER}

Comment by Robert Varga [ 31/Oct/15 ]

https://git.opendaylight.org/gerrit/29025

Comment by Tom Pantelis [ 31/Oct/15 ]

I tried ietf-restconf syntax error example again and I see the error reported by the syntax paerser:

[ERROR] no viable alternative at input '<EOF>' in module ietf-restconf on line 690 character 2
org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException: no viable alternative at input '<EOF>' in module ietf-restconf on line 690 character 2

However I also see this exception afterwards:

[ERROR] yang-to-sources: Unable to parse yang files from /home/mininet/ODL/mdsal/model/ietf/ietf-restconf/src/main/yang
java.lang.NullPointerException
at org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangStatementSourceImpl.writeLinkage(YangStatementSourceImpl.java:82)
at org.opendaylight.yangtools.yang.parser.stmt.reactor.SourceSpecificContext.loadStatements(SourceSpecificContext.java:295)
at org.opendaylight.yangtools.yang.parser.stmt.reactor.BuildGlobalContext.loadPhaseStatements(BuildGlobalContext.java:208)
at org.opendaylight.yangtools.yang.parser.stmt.reactor.BuildGlobalContext.buildEffective(BuildGlobalContext.java:174)
at org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor$BuildAction.buildEffective(CrossSourceStatementReactor.java:107)
at org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor$BuildAction.buildEffective(CrossSourceStatementReactor.java:125)
at org.opendaylight.yangtools.yang2sources.plugin.YangToSourcesProcessor.processYang(YangToSourcesProcessor.java:167)
at org.opendaylight.yangtools.yang2sources.plugin.YangToSourcesProcessor.execute(YangToSourcesProcessor.java:92)
at org.opendaylight.yangtools.yang2sources.plugin.YangToSourcesMojo.execute(YangToSourcesMojo.java:116)

The NPE is what is reported in the summary by maven:

[ERROR] Failed to execute goal org.opendaylight.yangtools:yang-maven-plugin:0.8.0-SNAPSHOT:generate-sources (binding) on project ietf-restconf: yang-to-sources: Unable to parse yang files from /home/mininet/ODL/mdsal/model/ietf/ietf-restconf/src/main/yang: NullPointerException -> [Help 1]

Even though the parser failed the invalid syntax, an NPE should not occur - it looks sloppy.

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