[YANGTOOLS-780] decimal64 fraction digits sub statement Created: 31/May/17  Updated: 10/Apr/22  Resolved: 27/Jul/18

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

Type: Bug
Reporter: Dhruv Bhardwaj Assignee: Unassigned
Resolution: Cannot Reproduce Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: All
Platform: All


External issue ID: 8573

 Description   

Hi,

For data type with following yang schema:

typedef pm-data-type {
type union {
type uint64;
type decimal64

{ fraction-digits 2; }

type decimal64

{ fraction-digits 17; }

}
}

ODL is thowing the following error:

java.lang.IllegalArgumentException: Invalid data "-99.9" for union type.
at org.opendaylight.yangtools.yang.data.util.AbstractStringUnionCodec.serialize(AbstractStringUnionCodec.java:47)
at org.opendaylight.yangtools.yang.data.codec.gson.JSONStringUnionCodec.serializeToWriter(JSONStringUnionCodec.java:30)
at org.opendaylight.yangtools.yang.data.codec.gson.JSONNormalizedNodeStreamWriter.writeValue(JSONNormalizedNodeStreamWriter.java:208)
at org.opendaylight.yangtools.yang.data.codec.gson.JSONNormalizedNodeStreamWriter.leafNode(JSONNormalizedNodeStreamWriter.java:98)
at org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWriter.wasProcessAsSimpleNode(NormalizedNodeWriter.java:152)

can you please help.



 Comments   
Comment by Peter Kajsa [ 01/Jun/17 ]

Hi,

the value '-99.9' does not match any of specified fraction-digits in the union type, so therefore the error occurs. For more details about fraction digits please see https://tools.ietf.org/html/rfc7950#section-9.3.4

BR.

Comment by Peter Kajsa [ 01/Jun/17 ]

Based on the discussion in yang-dev mailing list I reopened the bug..

Comment by Robert Varga [ 01/Jun/17 ]

Hello Dhruv,

can you enable logging on org.opendaylight.yangtools.yang.data.util.AbstractStringUnionCodec, please?

it should allow us to understand what went down in the sub-codec, i.e. there should be messages matching:

LOG.debug("Data {} did not match for {}", data, type, e);

which would pinpoint the source of the trouble.

Comment by Robert Varga [ 01/Jun/17 ]

Also, what version of ODL have you seen this?

Comment by Dhruv Bhardwaj [ 01/Jun/17 ]

I used carbon.
Will update with logs soon.

Thanks

Comment by Robert Varga [ 27/Jul/18 ]

No feedback, hence closing as cannot reproduce. If this issue crops up, feel free to reopen.

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