Default-stmt can be ambiguous

These two YANG “default” statements below are both acceptable to the ConfD.

  default 123;
  default "123";

I don’t know if quotes should be forbidden in default-stmt or not.
But as the ABNF from RFC-6020 claims:

string = < an unquoted string, as returned by >
< the scanner, that matches the rule >
< yang-string >

I’ll treat unquoted string as the correct format.
Then take this typedef-stmt for example.

typedef foo-type {
    type union {
        type string;
        type int32;
    }
    default 444;
}

From YANG grammar, I couldn’t tell what’s the actual type of default value “444”, it can be string, it also can be integer.

How does ConfD handle this?

Both statements are valid, and there is no semantical difference between them. Quoting is required in the cases specified by RFC 6020 - YANG - A Data Modeling Language for the Network Configuration Protocol (NETCONF), otherwise optional.

This means that the actual value is 123 - the quote characters are not part of the value.[quote=“lukai, post:1, topic:1619”]
typedef foo-type {
type union {
type string;
type int32;
}
default 444;
}

From YANG grammar, I couldn’t tell what’s the actual type of default value “444”, it can be string, it also can be integer.
[/quote]

From RFC 6020 - YANG - A Data Modeling Language for the Network Configuration Protocol (NETCONF)

   When a string representing a union data type is validated, the string
   is validated against each member type, in the order they are
   specified in the "type" statement, until a match is found.

Thus with that type definition, a default value will only ever match the string member, never int32. The corresponding text in RFC 7950 - The YANG 1.1 Data Modeling Language is a little different, because it takes into consideration that in the JSON encoding, strings and integers have different representation, and it is thus possible for a value to match the int32 member, while for XML encoding, a value can only match the string member.