From nobody Thu Apr 18 03:52:52 2024 Delivered-To: importer2@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=patchew-devel-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=patchew-devel-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1543393898954588.7004440534525; Wed, 28 Nov 2018 00:31:38 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 903BC882EA; Wed, 28 Nov 2018 08:31:37 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7EAD55D6AA; Wed, 28 Nov 2018 08:31:37 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 71ABA3F7CB; Wed, 28 Nov 2018 08:31:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wAS8VZT8003409 for ; Wed, 28 Nov 2018 03:31:35 -0500 Received: by smtp.corp.redhat.com (Postfix) id B7CEC600C2; Wed, 28 Nov 2018 08:31:35 +0000 (UTC) Received: from mx1.redhat.com (ext-mx01.extmail.prod.ext.phx2.redhat.com [10.5.110.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AF595600C0 for ; Wed, 28 Nov 2018 08:31:33 +0000 (UTC) Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6FBCB81F11 for ; Wed, 28 Nov 2018 08:31:32 +0000 (UTC) Received: by mail-wr1-f65.google.com with SMTP id r10so25321687wrs.10 for ; Wed, 28 Nov 2018 00:31:32 -0800 (PST) Received: from localhost.localdomain ([2001:b07:6468:f312:60a1:384e:4c17:72ad]) by smtp.gmail.com with ESMTPSA id 5sm1394542wmr.37.2018.11.28.00.31.28 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 28 Nov 2018 00:31:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=GLl/Z52rbB8VD5vjNHspVYRZAep3/NuoGY36e3hEEBg=; b=gmsMwcvVqaTfvaeWuQCqXb69jScVpyxi6/3ruMdcBKPVQvtAvyfm4yE/wNsDQjC9dZ RxJ+pnjttjY8tkrqj2vfCnHhx4cAPg6CImb0QtkkEG3/V1CWmP8EWSsfKw5iMg+q48nq sysrDLg2NpHjbJod1rr2qOx2fklrFZFNZATzWiw+7JUtRI/J1nRdflH15Rfp+oxEQ6Nq GnAjRlelg/A+qMiO5ebHu80CUk0UEnLOpuDGPTg5GJLYScCX76WTGEuzpwkZt6kUKJ3u FCNHm64epSMmlQGdwPBXw5/T+k7q6OI6kBYqDhZAjTgqiQAk3JwkXh83pvvqmba6Nhgy PqRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :mime-version:content-transfer-encoding; bh=GLl/Z52rbB8VD5vjNHspVYRZAep3/NuoGY36e3hEEBg=; b=fuWvCfC0/Gk1WYDyix8cZBeepvv6eLy4GpV/bVgpsYUWi0fp89OZpT31G7uJEmr8E4 XgHCtA7y0+N72By/eVpzQ5kAv/lRdjFa8kuEUkUawY0fDnEHJhScifSLET7f51nKjsxt BUYo8s2DyMm9jt4d+MC5s7YrF2kPkN73CDTYrO13ZkmaXopbDbHAQz9Wq6Kh8TehcQq9 qwY3gAE2MeHq9Dj0jrhGPh6N1gobcWaKSvUrxkk1q1aNe7x1EWi6pyI3f7Ecp2YDy1F8 8RsTLuQ5Ohb9ER9IWrnRM4vPXhHxaoRC3ntgCuj4tklSdsaco55BNJbWuGUW7L3zU+m9 +I/A== X-Gm-Message-State: AA+aEWYZYMgUQ03tdw1spz6PdQlf8FZpZSCw9ESV8HGCyHmAymMIIAUg Bo2f7eLsGnOGwrCyuxp5oQ3+cicQ X-Google-Smtp-Source: AFSGD/XESAlRBB4VJ67nEdpeRW7fC0InftD6HLhgZAJtrDOgLQ311sq49JDGEU+WNwSS0bOhsRKPlQ== X-Received: by 2002:adf:9bda:: with SMTP id e26mr19044405wrc.295.1543393890751; Wed, 28 Nov 2018 00:31:30 -0800 (PST) From: Paolo Bonzini To: patchew-devel@redhat.com Date: Wed, 28 Nov 2018 09:31:25 +0100 Message-Id: <20181128083125.9051-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 28 Nov 2018 08:31:32 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 28 Nov 2018 08:31:32 +0000 (UTC) for IP:'209.85.221.65' DOMAIN:'mail-wr1-f65.google.com' HELO:'mail-wr1-f65.google.com' FROM:'paolo.bonzini@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.24 (DKIM_SIGNED, DKIM_VALID, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS) 209.85.221.65 mail-wr1-f65.google.com 209.85.221.65 mail-wr1-f65.google.com X-RedHat-Possible-Forgery: Paolo Bonzini X-Scanned-By: MIMEDefang 2.83 on 10.5.110.25 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: patchew-devel@redhat.com Subject: [Patchew-devel] [PATCH] rest: the "data" field of results might not be there X-BeenThere: patchew-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Patchew development and discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: patchew-devel-bounces@redhat.com Errors-To: patchew-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 28 Nov 2018 08:31:37 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" For PATCH requests, for example, the user might be changing other fields only. Check whether the field is there before accessing it. Signed-off-by: Paolo Bonzini Reviewed-by: Caio Carrara --- api/rest.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/api/rest.py b/api/rest.py index 573cbf1..041e82d 100644 --- a/api/rest.py +++ b/api/rest.py @@ -552,9 +552,10 @@ class ResultSerializer(serializers.ModelSerializer): return obj.get_log_url(request) =20 def validate(self, data): - data_serializer_class =3D self.context['renderer'].result_data_ser= ializer_class - data_serializer_class(data=3Ddata['data'], - context=3Dself.context).is_valid(raise_excep= tion=3DTrue) + if 'data' in data: + data_serializer_class =3D self.context['renderer'].result_data= _serializer_class + data_serializer_class(data=3Ddata['data'], + context=3Dself.context).is_valid(raise_e= xception=3DTrue) return data =20 =20 --=20 2.19.1 _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel