Skip to content

fix: return 404 instead of 412 when dataset not found (#1176)#1289

Open
Shamarvey1 wants to merge 1 commit intoopenml:developfrom
Shamarvey1:fix-error-code-404
Open

fix: return 404 instead of 412 when dataset not found (#1176)#1289
Shamarvey1 wants to merge 1 commit intoopenml:developfrom
Shamarvey1:fix-error-code-404

Conversation

@Shamarvey1
Copy link
Copy Markdown

Closes #1176

Problem
Currently, when requesting a dataset that does not exist, the API returns HTTP 412 (Precondition Failed). However, according to standard HTTP semantics, a missing resource should return 404 (Not Found).

Solution
Updated the dataset retrieval endpoint to return HTTP 404 when the dataset is not found.

Specifically:

  • Modified the data($data_id) function in Api_data.php
  • When $dataset === false, the response now uses:
    returnError(111, $this->version, 404)

Why this approach

  • Keeps existing internal error code (111) unchanged
  • Only updates HTTP response code for correctness
  • Minimal and safe change without affecting other endpoints

Note
Other endpoints still use HTTP 412 for similar cases. This PR focuses on the main dataset retrieval endpoint. I can extend this behavior across other endpoints if desired.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Return error code 404 instead of 412 when dataset is not found

1 participant