Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xD75n-00000000K4t-08IH for pgsql-bugs@arkaria.postgresql.org; Sat, 03 Oct 2026 21:16:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xD75m-000000039U9-0NwV for pgsql-bugs@arkaria.postgresql.org; Sat, 03 Oct 2026 21:16:26 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xClrN-00000001TxO-0QPT for pgsql-bugs@lists.postgresql.org; Fri, 02 Oct 2026 22:36:09 +0000 Received: from mahout.postgresql.org ([2001:4800:3e1:1::227]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xClrK-000000004pt-1miL for pgsql-bugs@lists.postgresql.org; Fri, 02 Oct 2026 22:36:08 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=postgresql.org; s=20171124; h=Message-ID:Date:Reply-To:Cc:From:To:Subject: Content-Transfer-Encoding:MIME-Version:Content-Type:Sender:Content-ID: Content-Description:In-Reply-To:References; bh=lK5dbpJvC8/YpmFKUSY3PJrNj1RUKlCkj3HcuWOujMw=; b=pUpUxujZNGuOiyJZxpH7JTXlLG m4Yc3p1w4qGQhkf5U2umV+hdd1Dz1/IIv1k7Crl9dVXkQVTkAWGdkCCYd0iqIzvcuzmzaG0NnoDIW s+NbpvzaEaudazF+mR/bvfjd76Q8Dd9Z26yQLz8FeNN/1BQOJ5lH2Ab6ojShuigyzjP74+QkjXjl/ g6ilpCw5/zbOoxJ0/tnAzzIyTfKPycCIJTbRwVDjJ4HJLEGmtose8S50denP3u4CVr+oBK/l0PllQ ahIBa3M9mOybHCHz+RE3LgY1aeezdmg6CPyDz8qjIV8HY2E3PvS15l2wlimEJACFs/I+jFTloba/1 93QvNY/Q==; Received: from wrigleys.postgresql.org ([2a02:16a8:dc51::60]) by mahout.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xClrJ-00000000J9E-1s3J for pgsql-bugs@lists.postgresql.org; Fri, 02 Oct 2026 22:36:05 +0000 Received: from localhost ([127.0.0.1] helo=wrigleys.postgresql.org) by wrigleys.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xClrH-00000000sXN-3k7d for pgsql-bugs@lists.postgresql.org; Fri, 02 Oct 2026 22:36:03 +0000 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #19736: `JSON_OBJECT ... ABSENT ON NULL` accepts invalid keys when the value is NULL To: pgsql-bugs@lists.postgresql.org From: PG Bug reporting form Cc: theshallow27@gmail.com Reply-To: theshallow27@gmail.com, pgsql-bugs@lists.postgresql.org Date: Fri, 02 Oct 2026 22:35:57 +0000 Message-ID: <19736-3a44617ea5534c77@postgresql.org> X-Auto-Response-Suppress: All Auto-Submitted: auto-generated List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk The following bug has been logged on the website: Bug reference: 19736 Logged by: Shallow Email address: theshallow27@gmail.com PostgreSQL version: 18.6 Operating system: Linux Description: =20 When `ABSENT ON NULL` removes a pair because its value is SQL NULL, `JSON_OBJECT` also skips validation of that pair's key. The documented restrictions say that a key cannot be NULL and must be a scalar expression without a cast to JSON. Those restrictions should still apply when the value pair will be omitted. **Reproduction:** ```sql SELECT JSON_OBJECT((NULL::text) VALUE NULL::text ABSENT ON NULL RETURNING json); SELECT JSON_OBJECT((ARRAY[1,2]) VALUE NULL::text ABSENT ON NULL RETURNING json); ``` **Actual result:** Both statements return `{}`. **Expected result:** Both statements should reject the invalid key, as the key restrictions apply regardless of whether the value is omitted.