Re: [netmod] Question on when-construction involving identities not detected as an error during module compilation
Ladislav Lhotka <lhotka@nic.cz> Fri, 18 May 2018 10:24 UTC
Return-Path: <lhotka@nic.cz>
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 B68BD12D7E2 for <netmod@ietfa.amsl.com>; Fri, 18 May 2018 03:24:44 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -7
X-Spam-Level:
X-Spam-Status: No, score=-7 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_HI=-5] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key) header.d=nic.cz
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 Bu3_kEyVb-rZ for <netmod@ietfa.amsl.com>; Fri, 18 May 2018 03:24:42 -0700 (PDT)
Received: from mail.nic.cz (mail.nic.cz [217.31.204.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id EC50E12D77B for <netmod@ietf.org>; Fri, 18 May 2018 03:24:41 -0700 (PDT)
Received: from birdie (unknown [IPv6:2001:1488:fffe:6:e88e:f9ff:fe2e:3070]) by mail.nic.cz (Postfix) with ESMTPSA id 20AE1601AB for <netmod@ietf.org>; Fri, 18 May 2018 12:24:40 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1526639080; bh=McQGNOPItWoX7S86SmFE+sXCDRXavGVoARqNpCfQ4xw=; h=From:To:Date; b=KO88Pc/si+JhhZYE47Ax+Df2yH1Apdps3Z5LnoRXvQBPCd4QSxWdi1Kbur3RfDGJ5 AmmvwCqUUcxv3q+mceZorGSk32k0nm6AiBF9Jcddpg3P3EPBNEVRrtB5W5UcjzEvdB PTGzhWPyTWbLmiEICwNtEjrMm9ChPAPVHKiHXfsI=
Message-ID: <97af53bab97ebbb87168735298005674d6560447.camel@nic.cz>
From: Ladislav Lhotka <lhotka@nic.cz>
To: netmod@ietf.org
Date: Fri, 18 May 2018 12:24:57 +0200
In-Reply-To: <20180518.121626.115730608086823938.mbj@tail-f.com>
References: <DB6PR07MB4421DA0C615265DAA07CA9C294900@DB6PR07MB4421.eurprd07.prod.outlook.com> <20180518.121626.115730608086823938.mbj@tail-f.com>
Organization: CZ.NIC
Content-Type: text/plain; charset="UTF-8"
X-Mailer: Evolution 3.28.2
Mime-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Virus-Scanned: clamav-milter 0.99.2 at mail
X-Virus-Status: Clean
Archived-At: <https://mailarchive.ietf.org/arch/msg/netmod/r8g_Tb6_binAY8ah5qmkMQzDWuU>
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:24:45 -0000
On Fri, 2018-05-18 at 12:16 +0200, Martin Bjorklund wrote: > 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. I would also add that the XPath expression in the above module uses string comparison which is known to be problematic. Instead, you should use the new functions derived-from() and derived-from-or-self() introduced in YANG 1.1. Lada > > > /martin > > _______________________________________________ > netmod mailing list > netmod@ietf.org > https://www.ietf.org/mailman/listinfo/netmod -- Ladislav Lhotka Head, CZ.NIC Labs PGP Key ID: 0xB8F92B08A9F76C67
- [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