[netmod] Question on when-construction involving identities not detected as an error during module compilation

"Bogaert, Bart (Nokia - BE/Antwerp)" <bart.bogaert@nokia.com> Fri, 18 May 2018 10:10 UTC

Return-Path: <bart.bogaert@nokia.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 435E2127873 for <netmod@ietfa.amsl.com>; Fri, 18 May 2018 03:10:58 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.91
X-Spam-Level:
X-Spam-Status: No, score=-1.91 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, T_DKIMWL_WL_HIGH=-0.01] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key) header.d=nokia.onmicrosoft.com
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 HVi7I7ygWCP6 for <netmod@ietfa.amsl.com>; Fri, 18 May 2018 03:10:55 -0700 (PDT)
Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on0103.outbound.protection.outlook.com [104.47.1.103]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id ABF50129C70 for <netmod@ietf.org>; Fri, 18 May 2018 03:10:54 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia.onmicrosoft.com; s=selector1-nokia-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=pet+dRuJkyht92ke747fSPCaHRT7q8ZNNwVrlOBwfAw=; b=SJRgqUWirMIXRsbN1BkhuhfPcDqNoZYU16LdV6HmqI+XDs4ryR5wxTzZh2kzgxAUvuQl5K/RVp2XCfp9PFjfmdGBNcsgDFaKBYRAbYXMUtWv+t3rQtahqpYB7DwtEP/HFIq/arZMlnkcLeE5sWCeUT/lp9p1xrXUVeBEXSjgObk=
Received: from DB6PR07MB4421.eurprd07.prod.outlook.com (10.168.24.142) by DB6PR07MB3095.eurprd07.prod.outlook.com (10.170.223.154) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.797.5; Fri, 18 May 2018 10:10:52 +0000
Received: from DB6PR07MB4421.eurprd07.prod.outlook.com ([fe80::a53a:1f69:4c4b:dc0b]) by DB6PR07MB4421.eurprd07.prod.outlook.com ([fe80::a53a:1f69:4c4b:dc0b%13]) with mapi id 15.20.0797.005; Fri, 18 May 2018 10:10:52 +0000
From: "Bogaert, Bart (Nokia - BE/Antwerp)" <bart.bogaert@nokia.com>
To: "netmod@ietf.org" <netmod@ietf.org>
Thread-Topic: Question on when-construction involving identities not detected as an error during module compilation
Thread-Index: AdPukA/wNrVtvGb/QOCA4gfATSwNuA==
Date: Fri, 18 May 2018 10:10:52 +0000
Message-ID: <DB6PR07MB4421DA0C615265DAA07CA9C294900@DB6PR07MB4421.eurprd07.prod.outlook.com>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
x-originating-ip: [135.245.212.207]
x-ms-publictraffictype: Email
x-microsoft-exchange-diagnostics: 1; DB6PR07MB3095; 7:QKIPksmR5Xuv7kbZ3Lf+eJ+QYU/Lt2uK2tGNlzSJMeIntH3P6CaTML8GTLECHxSOVjaeSVVBbJvoIZEGuvV3fak3mmY3wF+WwkkcRW4jNMMB5FQ2Bui+F4aXm9reTWRfRMUicyLWwNiTTjf1xYwclDPWeCARqe9rs/LCMcWLKwtrpHYn75WnztQ7xBu0UqD3qwd+ieD4Kt95gkV3xCFIDHEv9To4qOG8WCJI80hbHyZSuVEi+PZuDkmU7sxWft++
x-ms-exchange-antispam-srfa-diagnostics: SOS;
x-ms-office365-filtering-ht: Tenant
x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(8989080)(5600026)(4534165)(4627221)(201703031133081)(201702281549075)(8990040)(48565401081)(2017052603328)(7193020); SRVR:DB6PR07MB3095;
x-ms-traffictypediagnostic: DB6PR07MB3095:
authentication-results: spf=none (sender IP is ) smtp.mailfrom=bart.bogaert@nokia.com;
x-microsoft-antispam-prvs: <DB6PR07MB3095D3E154F40F971B26E03894900@DB6PR07MB3095.eurprd07.prod.outlook.com>
x-exchange-antispam-report-test: UriScan:(28532068793085)(21748063052155)(79290750141951);
x-ms-exchange-senderadcheck: 1
x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(5005006)(8121501046)(3231254)(11241501184)(806099)(944501410)(52105095)(10201501046)(93006095)(93001095)(3002001)(6055026)(149027)(150027)(6041310)(20161123562045)(20161123564045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(6072148)(201708071742011)(7699016); SRVR:DB6PR07MB3095; BCL:0; PCL:0; RULEID:; SRVR:DB6PR07MB3095;
x-forefront-prvs: 0676F530A9
x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(396003)(376002)(346002)(39380400002)(366004)(39860400002)(189003)(199004)(26005)(53936002)(25786009)(5660300001)(14454004)(105586002)(6116002)(790700001)(478600001)(3846002)(3280700002)(3660700001)(86362001)(2501003)(2906002)(99286004)(5250100002)(66066001)(7696005)(68736007)(316002)(2900100001)(8936002)(81166006)(81156014)(1730700003)(8676002)(59450400001)(6916009)(6506007)(5630700001)(7736002)(102836004)(106356001)(55016002)(2351001)(33656002)(486006)(74316002)(6436002)(5640700003)(54896002)(6306002)(9686003)(97736004)(476003)(186003); DIR:OUT; SFP:1102; SCL:1; SRVR:DB6PR07MB3095; H:DB6PR07MB4421.eurprd07.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1;
received-spf: None (protection.outlook.com: nokia.com does not designate permitted sender hosts)
x-microsoft-antispam-message-info: qxVy8vzhPYTk31nBIyrkS/6uPJi4bNozrlEeSLAyOAIYhWHz8/MzzMzsI1daZVWa0pXJUSvMY8eXPPUCfhHm5FIvYJAR8rlKCGV2w1P7n6zM5aY895sm5qXRcFztBVHr8AR4v3XjBm4Y2qSkaFfbSMlv07gvpvUhgzoURxMp6vonmuytSPsrlJscvgmfoitcVay6/By5jboG+Jg5plrJ33GW0RhAFVY2RElnVpV44JE=
spamdiagnosticoutput: 1:99
spamdiagnosticmetadata: NSPM
Content-Type: multipart/alternative; boundary="_000_DB6PR07MB4421DA0C615265DAA07CA9C294900DB6PR07MB4421eurp_"
MIME-Version: 1.0
X-MS-Office365-Filtering-Correlation-Id: ad75416e-cfc8-4dee-e5a1-08d5bca7a2f7
X-OriginatorOrg: nokia.com
X-MS-Exchange-CrossTenant-Network-Message-Id: ad75416e-cfc8-4dee-e5a1-08d5bca7a2f7
X-MS-Exchange-CrossTenant-originalarrivaltime: 18 May 2018 10:10:52.1415 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 5d471751-9675-428d-917b-70f44f9630b0
X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR07MB3095
Archived-At: <https://mailarchive.ietf.org/arch/msg/netmod/MVwZfLbO1u7onYGurDn0EXgxhdg>
Subject: [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:10:58 -0000

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.

Best regards, Bart