Re: [netconf] Question on restconf empty list reply

Kent Watsen <kent@watsen.net> Mon, 24 February 2020 17:35 UTC

Return-Path: <01000170784458b8-bfa1e136-fff9-4eb3-a815-61e976fef629-000000@amazonses.watsen.net>
X-Original-To: netconf@ietfa.amsl.com
Delivered-To: netconf@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id AF1023A0F4A for <netconf@ietfa.amsl.com>; Mon, 24 Feb 2020 09:35:12 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.898
X-Spam-Level:
X-Spam-Status: No, score=-1.898 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key) header.d=amazonses.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 ETgkxqAy027h for <netconf@ietfa.amsl.com>; Mon, 24 Feb 2020 09:35:11 -0800 (PST)
Received: from a48-90.smtp-out.amazonses.com (a48-90.smtp-out.amazonses.com [54.240.48.90]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 5A5B73A0F4C for <netconf@ietf.org>; Mon, 24 Feb 2020 09:35:11 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=6gbrjpgwjskckoa6a5zn6fwqkn67xbtw; d=amazonses.com; t=1582565710; h=Content-Type:Mime-Version:Subject:From:In-Reply-To:Date:Cc:Content-Transfer-Encoding:Message-Id:References:To:Feedback-ID; bh=ARqw7zIoM7e0Yzf3FSRHNL1Q0pB9Z/oEd3+BBrVqTXo=; b=HjL3358VqVoE7rtkmufY75uJkq2TwWcBr/nigpKLCxB34rjAXggsm0hEkwHpC6bv kZN6RMEE7ZB6xvM1o/d+84Bd59lMOzBbvCW0zvktGFESHi8nf4KiKjlLsZzlUN1PlbM AQaHbnOR/f8hNXrE5I/dyyScX2cP/+PKjn92wmu4=
Content-Type: text/plain; charset="utf-8"
Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\))
From: Kent Watsen <kent@watsen.net>
In-Reply-To: <6ed11152-ab3d-d42b-f983-908de32bbef8@hagsand.se>
Date: Mon, 24 Feb 2020 17:35:10 +0000
Cc: Juergen Schoenwaelder <J.Schoenwaelder@jacobs-university.de>, "netconf@ietf.org" <netconf@ietf.org>
Content-Transfer-Encoding: quoted-printable
Message-ID: <01000170784458b8-bfa1e136-fff9-4eb3-a815-61e976fef629-000000@email.amazonses.com>
References: <4bca4ca8-0d9f-d986-4521-5c808a6e8a4d@hagsand.se> <20200223112829.rjd3zf53rybmmzvc@anna.jacobs.jacobs-university.de> <6ed11152-ab3d-d42b-f983-908de32bbef8@hagsand.se>
To: Olof Hagsand <olof@hagsand.se>
X-Mailer: Apple Mail (2.3445.104.11)
X-SES-Outgoing: 2020.02.24-54.240.48.90
Feedback-ID: 1.us-east-1.DKmIRZFhhsBhtmFMNikgwZUWVrODEw9qVcPhqJEI2DA=:AmazonSES
Archived-At: <https://mailarchive.ietf.org/arch/msg/netconf/Z7Oyq3tZ80Fv8MfD0P59R3jT4Vc>
Subject: Re: [netconf] Question on restconf empty list reply
X-BeenThere: netconf@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: NETCONF WG list <netconf.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/netconf>, <mailto:netconf-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/netconf/>
List-Post: <mailto:netconf@ietf.org>
List-Help: <mailto:netconf-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/netconf>, <mailto:netconf-request@ietf.org?subject=subscribe>
X-List-Received-Date: Mon, 24 Feb 2020 17:35:13 -0000

Hi Olof,


> What does "the empty lists exists or not" mean, how is an existing empty
> list different from a non-existent list wrt YANG? I would think that a
> YANG list have instances (= it exists), or it does not have instances (=
> is empty = does not exist).

Empty “list” (and “leaf-list”) handling seems to be related to the non-presence containers issue that has been tracked here: https://github.com/netmod-wg/yang-next/issues/88 (ps: just updated to reflect this thread).

Personally, I’m in the “explicit" camp.  That is, lists (and NP-containers) do not exist unless explicitly configured and they do not implicitly-disappear when empty.  My server distinguishes between missing (e.g., 404) and empty (204 for XML or 200 for JSON) lists.  Personally, I think it’s best to also return 204 (i.e., for JSON also) as its more RESTful and encoding-independent.   FWIW, RFC 8040 doesn’t mention the ability for GET to return 204, but it doesn’t disallow it either...


> Another related question is how the same request but for XML encoding
> should be treated, ie a YANG list x with no elements (empty
> list/non-existent)?

This issue is not encoding-specific, AFIACT.

The only list-related encoding issue I’m aware of is when  the query targets the list node directly, not a parent container, and the list contains more than one element.  In this case, it’s not possible to return a valid XML document, whereas there’s no issue with JSON.  

Off-topic, but a couple fixes have been proposed.  One creates an implicit wrapper node:

	==== start ====
	<collection xmlns=“foo”>
		<x>…</x>
		<x>…</x>
		<x>…</x>
	</collection>
	==== stop ====

Whereas another documents that, only in this case, is it possible to return an invalid XML document:

	==== start ====
	<x xmlns=“foo”>…</x>
	<x xmlns=“foo”>…</x>
	<x xmlns=“foo”>…</x>
	==== stop ====


>  GET /restconf/data/m:x
>  Accept: application/yang-data+xml
> 
> Is the reply "404 Not Found" status-line and error-tag value
> "invalid-value" (following the list resource does not exist)
> or, following the JSON [] (existing empty list) reasoning, a "204 No
> Content”?

Answered above, I think.


> Again apologizes for these basic questions,

No worries, sometimes it takes fresh eyes to see things  :)


Kent // contributor