Re: [yang-doctors] usage of mandatory node in an optional choice

Christian Hopps <chopps@chopps.org> Fri, 26 January 2018 11:36 UTC

Return-Path: <chopps@chopps.org>
X-Original-To: yang-doctors@ietfa.amsl.com
Delivered-To: yang-doctors@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 2AF2E12D779 for <yang-doctors@ietfa.amsl.com>; Fri, 26 Jan 2018 03:36:41 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -0.461
X-Spam-Level:
X-Spam-Status: No, score=-0.461 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_BRBL_LASTEXT=1.449, T_RP_MATCHES_RCVD=-0.01] autolearn=no autolearn_force=no
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id MnkEl8D2ZgM0 for <yang-doctors@ietfa.amsl.com>; Fri, 26 Jan 2018 03:36:40 -0800 (PST)
Received: from smtp.chopps.org (smtp.chopps.org [54.88.81.56]) by ietfa.amsl.com (Postfix) with ESMTP id E754D126CBF for <yang-doctors@ietf.org>; Fri, 26 Jan 2018 03:36:39 -0800 (PST)
Received: from tops.chopps.org (47-50-69-38.static.klmz.mi.charter.com [47.50.69.38]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by smtp.chopps.org (Postfix) with ESMTPSA id 523F462A7A; Fri, 26 Jan 2018 11:36:39 +0000 (UTC)
References: <CABCOCHRSrZQZBQqrRk7a4KfJT+_mp_n4reA7CEUaPfcCy6ypPQ@mail.gmail.com> <20180126.092228.468237320419748997.mbj@tail-f.com>
User-agent: mu4e 0.9.18; emacs 25.3.1
From: Christian Hopps <chopps@chopps.org>
To: Martin Bjorklund <mbj@tail-f.com>
Cc: andy@yumaworks.com, yang-doctors@ietf.org
Message-ID: <87tvv8g8hs.fsf@chopps.org>
In-reply-to: <20180126.092228.468237320419748997.mbj@tail-f.com>
Date: Fri, 26 Jan 2018 06:36:38 -0500
MIME-Version: 1.0
Content-Type: text/plain
Archived-At: <https://mailarchive.ietf.org/arch/msg/yang-doctors/rmJRXx35morO-57a49v0Ai9FZa0>
Subject: Re: [yang-doctors] usage of mandatory node in an optional choice
X-BeenThere: yang-doctors@ietf.org
X-Mailman-Version: 2.1.22
Precedence: list
List-Id: Email list of the yang-doctors directorate <yang-doctors.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/yang-doctors>, <mailto:yang-doctors-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/yang-doctors/>
List-Post: <mailto:yang-doctors@ietf.org>
List-Help: <mailto:yang-doctors-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/yang-doctors>, <mailto:yang-doctors-request@ietf.org?subject=subscribe>
X-List-Received-Date: Fri, 26 Jan 2018 11:36:41 -0000

Martin Bjorklund <mbj@tail-f.com> writes:
> Andy Bierman <andy@yumaworks.com> wrote:
>> Hi,
>>
>> I am working on a bug in our server, and I noticed the NACM rule choice
>> is a bit odd -- why is leaf path within implied case "path" a mandatory
>> node?
>> Why does this node have mandatory=true and none of the other leafs have
>> that?
...
>> Is this 'path' leaf really mandatory, given that the choice is optional?
>> Perhaps this is future-proofing -- making sure if the case is augmented
>> that the path node is still provided?  (If so, then why not do all
>> short-case
>> definitions this way?)
>
> Future-proofing is an interesting angle.  Maybe we should use *more*
> mandatory true in cases (!) like this...?

So I recently used a choice, and wondered why the "case" name values were not
included explicitly in the tree and instead the case choice was simply implied
by one of it's leaf nodes being present from underneath the case. It struck me
as an overly clever optimization. This seems to bear that feeling out.

If one has a choice with case nodes that are non-mandatory, it would
seem that yang would allow augments to these cases to exclusively select those
cases and it might seem that these augments are backward compatible
when in fact they are not:

  module foo;
  choice X {
    case A {
      leaf a {
        type boolean;
      }
    }
    case B {
      leaf b {
        type boolean;
      }
    }
  }

  module bar;
  augment /foo:X/foo:B/ {
    leaf bb {
      type string;
    }
  }

Now a client that only implements module foo might receive:

    <bar:bb>extra-info</bar:bb>

and have no idea that case B of choice X had been chosen.

So for choices to allow for augmenting with backward compatibility each case must
have at least one mandatory leaf in it. To my earlier point, this wouldn't have
been required if the case name itself had been included in the returned tree.

Thanks,
Chris.