Subject: [netmod] Can a grouping be defined to contain a 'list' with a 'key' but no key 'leaf' definition?

From: "Jernej Tuljak" <[email-masked]>
Date: Thu, 16 Jun 2016 11:33:49 +0200

I've had an interesting discussion on Stackoverflow whether the following is a valid grouping definition.

  grouping my-grouping {

    container foos {

      list foo {

        key name;

      }

    }

  }

Note that the key leaf is missing and is neither specified as a direct child nor via grouping usage inside the list. I argued that it is valid since the missing key leaf may be augmented at a later time upon grouping usage, but have failed to produce RFC text that would explicitly say so. In fact 6020bis-13 says the following in 7.8.2.:

Each such leaf identifier MUST refer to a
   child leaf of the list.  The leafs can be defined directly in
   substatements to the list, or in groupings used in the list.

So is this a valid grouping definition or would a compliant YANG compiler reject it with an error (pyang seems to allow it, so does our implementation). The same text is in RFC6020 and seems to suggest that the above is not allowed. Is this intentional?

I’m not asking whether doing this is good or bad practice.

Jernej

---

From: Martin Bjorklund <[email-masked]>
Date: Thu, 16 Jun 2016 12:01:56 +0200 (CEST)

"Jernej Tuljak" <[email-masked]> wrote:
> I've had an interesting discussion on Stackoverflow whether the
> following is a valid grouping definition.
> 
>  
> 
>   grouping my-grouping {
> 
>     container foos {
> 
>       list foo {
> 
>         key name;
> 
>       }
> 
>     }
> 
>   }
> 
>  
> 
> Note that the key leaf is missing and is neither specified as a direct
> child nor via grouping usage inside the list. I argued that it is
> valid since the missing key leaf may be augmented at a later time upon
> grouping usage, but have failed to produce RFC text that would
> explicitly say so. In fact 6020bis-13 says the following in 7.8.2.:
> 
>  
> 

I think this text clearly states that the example above is illegal.

/martin

> 
>  
> 
> So is this a valid grouping definition or would a compliant YANG
> compiler reject it with an error (pyang seems to allow it, so does our
> implementation). The same text is in RFC6020 and seems to suggest that
> the above is not allowed. Is this intentional?
> 
>  
>

---

From: Ladislav Lhotka <[email-masked]>
Date: Thu, 16 Jun 2016 15:09:33 +0200

> On 16 Jun 2016, at 12:01, Martin Bjorklund <[email-masked]> wrote:
> 

Then it would perhaps be better to say

OLD

   The leafs can be defined directly in substatements to the list,
   or in groupings used in the list.

NEW

   The leafs MUST be defined either directly in substatements to the list,
   or in groupings used in the list.

Lada

> _______________________________________________
> netmod mailing list
> [email-masked]
> https://www.ietf.org/mailman/listinfo/netmod

--
Ladislav Lhotka, CZ.NIC Labs
PGP Key ID: E74E8C0C