Skip to content

fix: allow deleting predictions with missing model version#9735

Open
Snehadas2005 wants to merge 1 commit into
HumanSignal:developfrom
Snehadas2005:delete-prediction
Open

fix: allow deleting predictions with missing model version#9735
Snehadas2005 wants to merge 1 commit into
HumanSignal:developfrom
Snehadas2005:delete-prediction

Conversation

@Snehadas2005
Copy link
Copy Markdown

@Snehadas2005 Snehadas2005 commented May 9, 2026

Summary
Fixes issue #9717 where predictions from imported tasks couldn't be deleted due to a missing model_version.

Changes

  • api.py: Made model_version optional and added handling for undefined/null strings sent by the frontend.
  • models.py: Updated delete_predictions to use model_version__isnull=True when targeting null versions.

Testing
Verified via curl to simulate the React frontend payload:

  • Command: curl -X DELETE ... -d '{"model_version": "undefined"}'
  • Result: Returns 200 OK and {"deleted_predictions": X}.
  • Logs: Server successfully processes the request without the previous RestValidationError.

Screenshots

  1. Terminal 1 (Server Logs): Shows the DELETE request returning a successful 200 status code instead of a 400 validation error
image
  1. Terminal 2 (Client Response): Confirms the API successfully accepts undefined as a version and returns a valid count of deleted predictions
image

@netlify
Copy link
Copy Markdown

netlify Bot commented May 9, 2026

👷 Deploy request for label-studio-docs-new-theme pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 8ebe73c

@netlify
Copy link
Copy Markdown

netlify Bot commented May 9, 2026

👷 Deploy request for heartex-docs pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 8ebe73c

@netlify
Copy link
Copy Markdown

netlify Bot commented May 9, 2026

Deploy Preview for label-studio-storybook ready!

Name Link
🔨 Latest commit 8ebe73c
🔍 Latest deploy log https://app.netlify.com/projects/label-studio-storybook/deploys/69ff59399a02710008fbd994
😎 Deploy Preview https://deploy-preview-9735--label-studio-storybook.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link
Copy Markdown

netlify Bot commented May 9, 2026

Deploy Preview for label-studio-playground ready!

Name Link
🔨 Latest commit 8ebe73c
🔍 Latest deploy log https://app.netlify.com/projects/label-studio-playground/deploys/69ff59394192d1000812fe4e
😎 Deploy Preview https://deploy-preview-9735--label-studio-playground.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions github-actions Bot added the fix label May 9, 2026
kcw2034 added a commit to kcw2034/label-studio that referenced this pull request May 11, 2026
…ersion

Issue HumanSignal#9717 — imported predictions whose model_version was missing could
not be deleted via DELETE /api/projects/<pk>/model-versions. Three legacy
import paths defaulted the field to the literal string 'undefined' while
other paths stored NULL, and the FE echoed those values back to a delete
endpoint that rejected anything falsy.

Backend
- Three import sites (data_import/api.py × 2, tasks/serializers.py) now
  store None instead of 'undefined' when the field is missing from input.
- DELETE /api/projects/<pk>/model-versions accepts JSON null, empty
  string, and the legacy 'undefined' string as "no model version" and
  routes them through a single isnull-aware delete path.
- Project.delete_predictions(None) sweeps NULL / '' / 'undefined' together
  so callers do not have to know about the pre-migration data layout.
- Migration tasks/0062 backfills 'undefined' rows to NULL.

Frontend
- PredictionsList renders "No model version" with an explanatory tooltip
  for falsy and legacy-'undefined' values; the stale === "undefined"
  comparison is gone.

Tests
- projects/tests/test_api.py adds TestDeletePredictionsAPI covering
  specific version, JSON null, empty string, legacy 'undefined', mixed
  null-ish sweep, and missing-key 400.

Related: review of upstream PR HumanSignal#9735.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant