HumanSignal/label-studio · error · ValidationError
Error validating prediction: {validation_errors}
Error message
Error validating prediction: {validation_errors} What it means
PredictionSerializer.validate() supports a pluggable validator via settings.CUSTOM_INTERFACE_PREDICTION_VALIDATOR (loaded with load_func). When that setting is configured and the custom validator returns non-empty errors for the prediction's result, ValidationError wraps and re-raises those errors verbatim.
Source
Thrown at label_studio/tasks/serializers.py:118
project = None
if 'task' in data:
project = data['task'].project
elif 'project' in data:
project = data['project']
ff_user = project.organization.created_by if project else 'auto'
# Only validate if we're updating the result field
if 'result' not in data:
return data
if not project:
raise ValidationError('Project is required for prediction validation')
custom_interface_validator = load_func(getattr(settings, 'CUSTOM_INTERFACE_PREDICTION_VALIDATOR', None))
if custom_interface_validator:
validation_errors = custom_interface_validator(project, data.get('result', []))
if validation_errors:
raise ValidationError(f'Error validating prediction: {validation_errors}')
if not flag_set('fflag_feat_utc_210_prediction_validation_15082025', user=ff_user):
# Skip validation if feature flag is not set
logger.info(f'Skipping prediction validation in PredictionSerializer for user {ff_user}')
return super().validate(data)
# Custom Interface projects normally keep the default <View></View>
# label_config and are validated above against output_schema instead.
if not project.label_config_is_not_default:
return super().validate(data)
# Validate prediction using LabelInterface
li = LabelInterface(project.label_config)
validation_errors = li.validate_prediction(data, return_errors=True)
if validation_errors:
raise ValidationError(f'Error validating prediction: {validation_errors}')
View on GitHub (pinned to 0b49e9b539)
Solutions
- Read the returned validation_errors detail — it comes from your custom validator, so fix the result payload to satisfy it
- Check the CUSTOM_INTERFACE_PREDICTION_VALIDATOR implementation in your settings to understand its rules
- Update the custom validator if it is stale relative to the current label config
- Temporarily remove/adjust the setting to confirm it is the source of the rejection
Example fix
// before CUSTOM_INTERFACE_PREDICTION_VALIDATOR = 'myapp.validators.old_pred_validator' // after CUSTOM_INTERFACE_PREDICTION_VALIDATOR = None # or an updated validator matching current label config
Defensive patterns
Strategy: try-catch
Validate before calling
from django.conf import settings
def precheck_with_custom_validator(project, result):
loader = getattr(settings, 'CUSTOM_INTERFACE_PREDICTION_VALIDATOR', None)
if not loader:
return
validator = __import__(loader.rsplit('.', 1)[0], fromlist=['x'])
fn = getattr(validator, loader.rsplit('.', 1)[1])
errors = fn(project, result)
if errors:
raise ValueError(f"custom validator rejects result: {errors}") Type guard
def custom_validator_configured(settings) -> bool:
return bool(getattr(settings, 'CUSTOM_INTERFACE_PREDICTION_VALIDATOR', None)) Try / catch
from rest_framework.exceptions import ValidationError
try:
ser = PredictionSerializer(data=payload)
ser.is_valid(raise_exception=True)
except ValidationError as e:
errors = e.detail
# detail is the custom validator's message — fix result per its rules
logger.error("custom prediction validation failed: %s", errors) Prevention
- Keep the custom validator implementation in sync with current label configs
- Read the wrapped validation_errors in the exception detail — they come from your own validator
- Version the validator alongside label config changes
- Test validator changes against representative prediction payloads before deploy
When it happens
Trigger: Creating/updating a prediction whose result violates rules enforced by the custom validator configured in settings (e.g. organization-specific schema constraints on allowed labels/types), with the prediction-validation feature in play.
Common situations: Deployments with a custom validator from an older project config that rejects results from newly changed label configs; mismatches after editing the labeling interface; validator expecting a different result shape than the client sends.
Related errors
- Each item in prediction result should be dict
- Incorrect format {type(result)} for prediction result {resul
- Project is required for prediction validation
- Validation failed on {}: {}
- Label config contains non-unique names:
AI-assisted analysis of HumanSignal/label-studio@0b49e9b539 (2026-08-29).
Data as JSON: /api/errors/02321212768bf930.
Report an issue: GitHub.