Re: [netmod] Question on when-construction involving identities not detected as an error during module compilation
Martin Bjorklund <mbj@tail-f.com> Fri, 18 May 2018 10:16 UTC
Return-Path: <mbj@tail-f.com>
X-Original-To: netmod@ietfa.amsl.com
Delivered-To: netmod@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id CB3CC129C70 for <netmod@ietfa.amsl.com>; Fri, 18 May 2018 03:16:30 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.901
X-Spam-Level:
X-Spam-Status: No, score=-1.901 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, SPF_PASS=-0.001] autolearn=ham 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 yPTg_0l0dv9E for <netmod@ietfa.amsl.com>; Fri, 18 May 2018 03:16:29 -0700 (PDT)
Received: from mail.tail-f.com (mail.tail-f.com [46.21.102.45]) by ietfa.amsl.com (Postfix) with ESMTP id 1B6D0129C6D for <netmod@ietf.org>; Fri, 18 May 2018 03:16:29 -0700 (PDT)
Received: from localhost (unknown [173.38.220.61]) by mail.tail-f.com (Postfix) with ESMTPSA id 7170E1AE012C; Fri, 18 May 2018 12:16:27 +0200 (CEST)
Date: Fri, 18 May 2018 12:16:26 +0200
Message-Id: <20180518.121626.115730608086823938.mbj@tail-f.com>
To: bart.bogaert@nokia.com
Cc: netmod@ietf.org
From: Martin Bjorklund <mbj@tail-f.com>
In-Reply-To: <DB6PR07MB4421DA0C615265DAA07CA9C294900@DB6PR07MB4421.eurprd07.prod.outlook.com>
References: <DB6PR07MB4421DA0C615265DAA07CA9C294900@DB6PR07MB4421.eurprd07.prod.outlook.com>
X-Mailer: Mew version 6.7 on Emacs 24.5 / Mule 6.0 (HANACHIRUSATO)
Mime-Version: 1.0
Content-Type: Text/Plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Archived-At: <https://mailarchive.ietf.org/arch/msg/netmod/qeWLMl5xtX3lSQ939kQTV-jcBAo>
Subject: Re: [netmod] Question on when-construction involving identities not detected as an error during module compilation
X-BeenThere: netmod@ietf.org
X-Mailman-Version: 2.1.22
Precedence: list
List-Id: NETMOD WG list <netmod.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/netmod>, <mailto:netmod-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/netmod/>
List-Post: <mailto:netmod@ietf.org>
List-Help: <mailto:netmod-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/netmod>, <mailto:netmod-request@ietf.org?subject=subscribe>
X-List-Received-Date: Fri, 18 May 2018 10:16:31 -0000
Hi, "Bogaert, Bart (Nokia - BE/Antwerp)" <bart.bogaert@nokia.com> wrote: > Hi, > > We have a question on YANG module compilation. Assume the following > model: > > module test-feat-compile { > yang-version 1.1; > namespace "http://www.example.com/test-feat-compile"; > prefix "tfc"; > > identity failure-reason { > description > "The reason a failure occurred."; > } > > identity no-failure { > description > "No failure has occurred."; > } > > identity general-error { > base failure-reason; > description > "A general error occurred."; > } > > container failure { > description > "Objects associated with a failure."; > > leaf failure-reason { > type identityref { > base failure-reason; > } > description > "The reason the failure occurred."; > } > > leaf failure-string { > when "../failure-reason != 'no-failure'" { > description > "Only valid when there is a failure."; > } > type string; > description > "A text string indicating the reason for the failure when > either no defined reason exists or additional information > is available beyond the definition of the reason."; > } > } > } > > Looking at the when clause there is something obviously wrong (at > least this is how I see it): > > * The leaf 'failure-reason' is of type identityref with 'failure-reason' > as base > * Identity 'no-failure' does not have 'failure-reason' as base (see it > as having been forgotten) > Question is: shouldn't this be reported at compile time? Pyang > doesn't and the other compiler we use doesn't report this either. > > Even when 'no-failure' is modified into some arbitrary string it is > still accepted while this arbitrary string is not defined anywhere as > identity. > > And when it comes to the correct syntax, RFC 7950 states (section > 9.1.3) that identities in must and when statements should be prefixed > (so tfc:no-failure in this case). Also this "violation" passes. > > So: what can we expect to be checked at compile time in this case? > Now you can only detect these anomalies when using a system supporting > the modules and detect that things do not work as intended. It would > be better to have these erroneous constructions being detected at > compile time. If there is something in the RFC that allows the > compiler to behave as it does now it would be good to know. Strictly speaking, the "when" expressions are not erroneous; they are proper XPath expressions that happen to always return "false". A good compiler could detect this and produce a warning, but it would be incorrect to flag this as an error. /martin
- [netmod] Question on when-construction involving … Bogaert, Bart (Nokia - BE/Antwerp)
- Re: [netmod] Question on when-construction involv… Martin Bjorklund
- Re: [netmod] ?==?utf-8?q? Question on when-constr… Michal Vaško
- Re: [netmod] Question on when-construction involv… Ladislav Lhotka