Skip to content

Fix #9633: Tasks won't load with only prediction (no annotation)#9676

Open
JiwaniZakir wants to merge 1 commit intoHumanSignal:developfrom
JiwaniZakir:fix/9633-tasks-won-t-load-with-only-prediction-no
Open

Fix #9633: Tasks won't load with only prediction (no annotation)#9676
JiwaniZakir wants to merge 1 commit intoHumanSignal:developfrom
JiwaniZakir:fix/9633-tasks-won-t-load-with-only-prediction-no

Conversation

@JiwaniZakir
Copy link
Copy Markdown

Closes #9633

Reason for change

Fixes a crash when opening a task that has predictions but no annotations. In web/libs/editor/src/stores/Annotation/store.js, the addAnnotationFromPrediction action iterates over prediction results and calls r.id.replace(/#.*$/, ...) to rewrite area IDs. When a result's id field is a number (as returned by some backends), .replace() does not exist on the value, producing:

Uncaught (in promise) TypeError: e.id.replace is not a function
    addAnnotationFromPrediction store.js:537

Fix

One-line change in store.js line 537:

// before
const id = r.id.replace(/#.*$/, `#${c.id}`);

// after
const id = String(r.id).replace(/#.*$/, `#${c.id}`);

Coercing r.id to a string before calling .replace() handles both string and numeric IDs without changing behavior for the string case.

Screenshots

N/A — no visible UI change; the fix restores previously broken behavior (task loads and prediction is applied as a draft annotation).

Rollout strategy

No feature flag needed. Pure bug fix with no API or data model changes.

Testing

A unit test was added in web/libs/editor/src/stores/Annotation/__tests__/store.test.js:

"addAnnotationFromPrediction handles numeric result ids without throwing (e.id.replace bug)"

The test constructs a prediction whose result contains a numeric id (12345), calls addAnnotationFromPrediction, and asserts no exception is thrown and the returned annotation is defined. This directly reproduces the failing path that caused the crash in production.

Manual verification: opening a task with predictions and no annotations no longer throws in the console and the prediction is correctly loaded into the labeling interface as a draft annotation.

Risks

Minimal. String(value) on an already-string value is a no-op, so existing behavior for string IDs is unchanged. Numeric IDs are now safely coerced rather than crashing.

Reviewer notes

The only changed production line is store.js:537. The rest of the diff is the new test case.


This PR was created with AI assistance (Claude). The changes were reviewed by quality gates and a critic model before submission.

@netlify
Copy link
Copy Markdown

netlify bot commented Apr 2, 2026

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

Visit the deploys page to approve it

Name Link
🔨 Latest commit 5e16fc0

@netlify
Copy link
Copy Markdown

netlify bot commented Apr 2, 2026

👷 Deploy request for heartex-docs pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 5e16fc0

@netlify
Copy link
Copy Markdown

netlify bot commented Apr 2, 2026

Deploy Preview for label-studio-playground ready!

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

QR Code

Use your smartphone camera to open QR code link.

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

@netlify
Copy link
Copy Markdown

netlify bot commented Apr 2, 2026

Deploy Preview for label-studio-storybook ready!

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

QR Code

Use your smartphone camera to open QR code link.

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

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tasks won't load with only prediction (no annotation)

1 participant