Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id A7E05200D33 for ; Wed, 8 Nov 2017 13:24:20 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id A6578160BE0; Wed, 8 Nov 2017 12:24:20 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 46409160BDA for ; Wed, 8 Nov 2017 13:24:19 +0100 (CET) Received: (qmail 25028 invoked by uid 500); 8 Nov 2017 12:24:18 -0000 Mailing-List: contact dev-help@brooklyn.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@brooklyn.apache.org Delivered-To: mailing list dev@brooklyn.apache.org Received: (qmail 25015 invoked by uid 99); 8 Nov 2017 12:24:18 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 08 Nov 2017 12:24:18 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 4EDADC4C6D for ; Wed, 8 Nov 2017 12:24:17 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.379 X-Spam-Level: X-Spam-Status: No, score=0.379 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_SORBS_SPAM=0.5, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd1-us-west.apache.org (amavisd-new); dkim=pass (1024-bit key) header.d=cloudsoftcorp.com Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id PqTpYx3sf2Oc for ; Wed, 8 Nov 2017 12:24:14 +0000 (UTC) Received: from mail-lf0-f41.google.com (mail-lf0-f41.google.com [209.85.215.41]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id 6C2F55FD1B for ; Wed, 8 Nov 2017 12:24:14 +0000 (UTC) Received: by mail-lf0-f41.google.com with SMTP id r135so2918213lfe.5 for ; Wed, 08 Nov 2017 04:24:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudsoftcorp.com; s=google; h=from:subject:to:references:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding; bh=xZ1eSpXjUey+NerrbAqQm0OfHQz8PxkBMppyfXYhPsQ=; b=EXqsm8nRzfnhW8Wapo2PW32nkco5sq4ur8nDhoZs7G5SxUE82UexdfDuIzF3dxmAh+ ZIF8HJuYNXbsziMoe6y1cSQI3a9p1+5Hv/3uZQplaQbpwJHvX6N3qtEWlpdbRDoWHr0r r0wlV9HsfKHa9Da3SIMg4T5WOlH2o12i4bPzA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:references:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=xZ1eSpXjUey+NerrbAqQm0OfHQz8PxkBMppyfXYhPsQ=; b=aULaCj+n0dbeMQ57DAuYuwgiJJ8aFa/zn80gTpNRjuX67f+ZTbP0XXz5e4QDekMuM/ 7mKOwtN4klZteSY7jZi6Ob9X4c3gc72IJwJVVCgpphLdKgqOs5szNLBGizHTpe62cMvI g7h/e1Asek8vKZ9Z3H/ZWXfXNdGBdQfY78+zcgUAkkO1XeLeqwt6+jFK2bvujQQmQYPw jPiddNMvwIcjKj95mEPVunNM7agQYX686IuEPiyJxdg4355aBPapciTFRpQdSlnLI+XB VZxsGrHE1JfBD9VdsCSCpjaUpFGoXj3S6rgzIt4ei6OjvDNRugpEcX1Sqajkdwt7LyVr QfjA== X-Gm-Message-State: AJaThX4Udf4OjxUZ8KVM63gWSAY2Mw6r2rt5UraGDEztEecagS3BxVRI GHqSIjUJ3dGWMVfSJ7eQT7XxQ9CChO188NlTZG4YT9HJ71GHQj6gFblPvaUDlIDXYYbV0nN8pNl 1ZypBMVuomweHag== X-Google-Smtp-Source: ABhQp+Tg97Vi5kpXVbG/WOXkz8/5dzHqbH2F20pFEP/aLPoCQ+9qrZiAE5VUFYyKB1I4tw1+Qh6xFA== X-Received: by 10.46.84.82 with SMTP id y18mr172075ljd.74.1510143852543; Wed, 08 Nov 2017 04:24:12 -0800 (PST) Received: from Sarahs-iPhone.home (host86-186-241-170.range86-186.btcentralplus.com. [86.186.241.170]) by smtp.googlemail.com with ESMTPSA id n63sm763659ljb.1.2017.11.08.04.24.11 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Nov 2017 04:24:11 -0800 (PST) From: Alex Heneveld X-Google-Original-From: Alex Heneveld Subject: Re: Brooklyn REST API - omitting fields in JSON objects To: dev@brooklyn.apache.org References: Message-ID: <4fd6ffc8-5092-d758-6e04-7148b4233a6e@CloudsoftCorp.com> Date: Wed, 8 Nov 2017 12:24:06 +0000 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Legal-Virus-Advice: Whilst all reasonable care has been taken to avoid the transmission of viruses, it is the responsibility of the recipient to ensure that the onward transmission, opening or use of this message and any attachments will not adversely affect its systems or data. No responsibility is accepted by Cloudsoft Corporation Limited in this regard and the recipient should carry out such virus and other checks as it considers appropriate. X-Legal-Confidentiality: This e-mail message is confidential and for use by the addressee only. If the message is received by anyone other than the addressee, please return the message to the sender by replying to it and then delete the message from your computer. Internet e-mails are not necessarily secure. Cloudsoft Corporation Limited does not accept responsibility for changes made to this message after it was sent. X-Legal-Company-Info: Cloudsoft Corporation Limited. Registered in Scotland. Number: SC349230. Registered Office: 13 Dryden Place, Edinburgh, EH9 1RP. archived-at: Wed, 08 Nov 2017 12:24:20 -0000 note previously we were inconsistent, with NON_NULL used some places, NON_EMPTY elsewhere, and no exclusions elsewhere, and in many places without much thought. so we have three options: 1 - dogmatic - remove all `@Include(NON_*)` annotations 2 - compatibility-first - restore anything changed since 0.12.0 3 - forward-looking - leave as is, with documentation added that empty/null fields may not be included in json response objects, and release note that this has been applied in more places (note that 1 is technically a breaking change if i had code that expected not to see a field unless it was non-empty ... it will probably break tests) i tend to think API consumers impacted by this are small and can take the pain, and better to have a nice set of API response objects for new users. and when i see lots of nulls and empties in an api response object i think the designers care more about dogma than human users. i don't expect the v2 rest api will land any time soon. so i am strongly for option 3, taking the ui pain now, but i'll defer if i'm a singleton --a On 08/11/2017 11:35, Geoff Macartney wrote: > My tuppence worth - agree with Thomas, it looks like a change best done in > a V2. Since it's actually a real breakage for the API it would be at least > worth passing through a deprecation cycle, but as Alex points out there's > no efficient way to do that. The cost of restoring ugliness in the response > objects at least keeps the pain away from client API consumers. > > G > > On Wed, 8 Nov 2017 at 11:22 Graeme Miller wrote: > >> Hello, >> >> I agree with Thomas here. This seems like an API breaking change, and >> should be reserved for V2 if it at all. >> I lean towards reverting. >> >> Regards, >> Graeme >> >> On 8 November 2017 at 10:01, Thomas Bouron < >> thomas.bouron@cloudsoftcorp.com> >> wrote: >> >>> Hi all. >>> >>> I'm not a fan of excluding fields from the JSON payload, if empty, for >> few >>> reasons: >>> 1. this is a breaking change for the UI and CLI which will be time >>> consuming to fix (very fiddly to guard against this in JS for example) >>> 2. this makes it harder to design clients, because you need to guard >>> against the presence of those fields. The swagger page displays all >> fields >>> leading the user/dev to think that they are always returned in the >> payload >>> 3. I don't think it saves bandwidth to remove a `constraints: []` from >> the >>> final JSON. If you want to have a smaller payload, I would much prefer to >>> set a query string flag to restrict (or expand) the full body, something >>> like `?summary=true` => returns only necessary information. >>> >>> Now, my comments apply for the API endpoints under /v1 only. I'm all in >>> favour of break things with a v2 API though. >>> >>> Best. >>> >>> On Mon, 6 Nov 2017 at 15:17 Alex Heneveld < >> alex.heneveld@cloudsoftcorp.com >>> wrote: >>> >>>> Hi All- >>>> >>>> Until recently our REST API returned full records in most cases, >>>> including often lots of empty lists and maps and sometimes nulls -- >> such >>>> as `constraints: []` on all config keys. >>>> >>>> The widespread preference in REST / JSON community seems to be to omit >>>> these unless there is a very good reason for having them, e.g. Google >>>> JSON Style Guide [1]. >>>> >>>> Recently in replacing deprecated FasterXML annotations with newer ones >>>> many fields were changed to be included only if NON_EMPTY, in line with >>>> that preference, but this is technically a breaking change. And it's >>>> not just technical, as there are a few places in UI code which assume >>>> fields exist which now do break. These are easy to fix once they're >>>> encountered at runtime but tedious to ensure no problems at design >> time. >>>> Thus we have two choices: >>>> >>>> * Yes, make this break now. This (v1.0) is probably the best time. >>>> There is no efficient way to pass this through a deprecation cycle. >> Cost >>>> is adding to release nodes and REST API client breakages and fixes. >>>> * No, revert any `Include(NON_EMPTY)` annotations recently introduced >> to >>>> be strict about backwards-compatibility here. Cost is restoring old >>>> behaviour and bloat/ugliness in the API response objects. >>>> >>>> I have a preference for "Yes", roll-forward and tolerate some breakages >>>> with the shift to 1.0. >>>> >>>> Best >>>> Alex >>>> >>>> >>>> [1] >>>> >>>> https://google.github.io/styleguide/jsoncstyleguide. >>> xml#Empty/Null_Property_Values >>>> -- >>> Thomas Bouron • Senior Software Engineer @ Cloudsoft Corporation • >>> https://cloudsoft.io/ >>> Github: https://github.com/tbouron >>> Twitter: https://twitter.com/eltibouron >>>