Fix #9633: Tasks won't load with only prediction (no annotation)#9676
Open
JiwaniZakir wants to merge 1 commit intoHumanSignal:developfrom
Open
Fix #9633: Tasks won't load with only prediction (no annotation)#9676JiwaniZakir wants to merge 1 commit intoHumanSignal:developfrom
JiwaniZakir wants to merge 1 commit intoHumanSignal:developfrom
Conversation
👷 Deploy request for label-studio-docs-new-theme pending review.Visit the deploys page to approve it
|
👷 Deploy request for heartex-docs pending review.Visit the deploys page to approve it
|
✅ Deploy Preview for label-studio-playground ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for label-studio-storybook ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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, theaddAnnotationFromPredictionaction iterates over prediction results and callsr.id.replace(/#.*$/, ...)to rewrite area IDs. When a result'sidfield is a number (as returned by some backends),.replace()does not exist on the value, producing:Fix
One-line change in
store.jsline 537:Coercing
r.idto 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:The test constructs a prediction whose result contains a numeric
id(12345), callsaddAnnotationFromPrediction, 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.