From f3770fbc62ceb181c53d2f8910e62a279e7f0137 Mon Sep 17 00:00:00 2001 From: Shamarvey1 Date: Thu, 16 Apr 2026 19:08:59 +0530 Subject: [PATCH] fix: prevent duplicate dataset uploads using file_id check --- openml_OS/models/api/v1/Api_data.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/openml_OS/models/api/v1/Api_data.php b/openml_OS/models/api/v1/Api_data.php index 294d1300..c27bedab 100644 --- a/openml_OS/models/api/v1/Api_data.php +++ b/openml_OS/models/api/v1/Api_data.php @@ -1276,6 +1276,18 @@ private function data_upload() { /* * * * * THE ACTUAL INSERTION * * * */ + // 🔍 Check for duplicate dataset using file_id + // 🔍 Check for duplicate dataset using file_id + $existing = $this->Dataset->getWhereSingle('file_id = ' . $file_id); + if ($existing != false) { + $this->returnError( + 135, + $this->version, + $this->openmlGeneralErrorCode, + "Dataset with same file already exists" + ); + return; + } $id = $this->Dataset->insert($dataset); if (!$id) { $this->returnError(134, $this->version);