From 18b9acba03116212cc5d5083deab7c75165078e0 Mon Sep 17 00:00:00 2001 From: Andre Klapper Date: Fri, 13 Feb 2026 15:31:30 +0100 Subject: [PATCH] Conduit: Improve error handling calling file.uploadchunk/file.querychunks without PHID Summary: Throw a proper error code and error_info, like similar `file.download` and `file.info` already do. Test Plan: * Go to http://phorge.localhost/conduit/method/file.uploadchunk and http://phorge.localhost/conduit/method/file.querychunks , click "Call Method" * Before this patch, get a generic "ERR-CONDUIT-CORE" error code. * After this patch, get a "ERR-BAD-PHID" error code and the error info `No such file exists.` Reviewers: O1 Blessed Committers, valerio.bozzolan Reviewed By: O1 Blessed Committers, valerio.bozzolan Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Differential Revision: https://we.phorge.it/D26754 --- .../files/conduit/FileQueryChunksConduitAPIMethod.php | 9 +++++++++ .../files/conduit/FileUploadChunkConduitAPIMethod.php | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/src/applications/files/conduit/FileQueryChunksConduitAPIMethod.php b/src/applications/files/conduit/FileQueryChunksConduitAPIMethod.php index e0929ef8c4..847c91e3df 100644 --- a/src/applications/files/conduit/FileQueryChunksConduitAPIMethod.php +++ b/src/applications/files/conduit/FileQueryChunksConduitAPIMethod.php @@ -21,10 +21,19 @@ final class FileQueryChunksConduitAPIMethod return 'list'; } + protected function defineErrorTypes() { + return array( + 'ERR-BAD-PHID' => pht('Must pass a PHID.'), + ); + } + protected function execute(ConduitAPIRequest $request) { $viewer = $request->getUser(); $file_phid = $request->getValue('filePHID'); + if (!$file_phid) { + throw new ConduitException('ERR-BAD-PHID'); + } $file = $this->loadFileByPHID($viewer, $file_phid); $chunks = $this->loadFileChunks($viewer, $file); diff --git a/src/applications/files/conduit/FileUploadChunkConduitAPIMethod.php b/src/applications/files/conduit/FileUploadChunkConduitAPIMethod.php index eab46c4992..0dcce998ca 100644 --- a/src/applications/files/conduit/FileUploadChunkConduitAPIMethod.php +++ b/src/applications/files/conduit/FileUploadChunkConduitAPIMethod.php @@ -24,10 +24,19 @@ final class FileUploadChunkConduitAPIMethod return 'void'; } + protected function defineErrorTypes() { + return array( + 'ERR-BAD-PHID' => pht('Must pass a PHID.'), + ); + } + protected function execute(ConduitAPIRequest $request) { $viewer = $request->getUser(); $file_phid = $request->getValue('filePHID'); + if (!$file_phid) { + throw new ConduitException('ERR-BAD-PHID'); + } $file = $this->loadFileByPHID($viewer, $file_phid); $start = $request->getValue('byteStart'); -- 2.51.2