From 448a342d9f8a739591671cf3111bf913e5106c17 Mon Sep 17 00:00:00 2001 From: Andre Klapper Date: Fri, 2 Jan 2026 21:56:56 +0100 Subject: [PATCH] Conduit: Improve error handling calling flag.edit without objectPHID Summary: Avoid an ugly AphrontQueryException. Throw a proper error code instead. ``` EXCEPTION: (AphrontQueryException) #1048: Column 'objectPHID' cannot be null at [/src/infrastructure/storage/connection/mysql/AphrontBaseMySQLDatabaseConnection.php:396] ``` Closes T16442 Test Plan: Go to http://phorge.localhost/conduit/method/flag.edit/ and press the "Call Method" button Reviewers: O1 Blessed Committers, mainframe98 Reviewed By: O1 Blessed Committers, mainframe98 Subscribers: mainframe98, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Maniphest Tasks: T16442 Differential Revision: https://we.phorge.it/D26644 --- .../flag/conduit/FlagEditConduitAPIMethod.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/applications/flag/conduit/FlagEditConduitAPIMethod.php b/src/applications/flag/conduit/FlagEditConduitAPIMethod.php index 3bc0d7e29e..b83db1fd0b 100644 --- a/src/applications/flag/conduit/FlagEditConduitAPIMethod.php +++ b/src/applications/flag/conduit/FlagEditConduitAPIMethod.php @@ -22,9 +22,18 @@ final class FlagEditConduitAPIMethod extends FlagConduitAPIMethod { return 'dict'; } + protected function defineErrorTypes() { + return array( + 'ERR-BAD-PHID' => pht('Must pass a PHID.'), + ); + } + protected function execute(ConduitAPIRequest $request) { $user = $request->getUser()->getPHID(); $phid = $request->getValue('objectPHID'); + if ($phid === null) { + throw new ConduitException('ERR-BAD-PHID'); + } $new = false; $flag = id(new PhabricatorFlag())->loadOneWhere( -- 2.51.2