After running a job, a mapper generates and applies mappings to the job’s source data. Schema enforcement then reviews these mappings for any invalidations.

If a job requires review, you’ll see the Result.status marked as NEEDS_REVIEW. The validation errors can be found in the Mapping.message property after querying for a job’s mappings.

Structure of Validation Errors

The Mapping.message property now contains a ValidationErrorSchema object with two main components:

  1. record_errors: Specific errors for individual fields
  2. global_errors: Errors that apply to multiple records or the entire dataset

Record Errors

Record errors are field-specific issues. They’re represented as an object where each key is the name of the problematic field, and the value is a FieldError object:

interface FieldError {
  error_message: string;
  error_type: string;
}
  • error_message: A description of why the field was flagged for review
  • error_type: The category of the error (e.g., “Type Error”, “Unique Error”, “Schema Error”)

Global Errors

Global errors affect multiple records or the entire dataset. They’re grouped by error type:

interface GlobalErrors {
  error_types: {
    [key: string]: GlobalErrorDetail[];
  };
}

interface GlobalErrorDetail {
  error_message: string;
  error_indices: number[];
  error_fields: string[];
}
  • error_message: A description of the global error
  • error_indices: The indices of affected records
  • error_fields: The fields involved in the error

Error Types

The system recognizes three main types of errors:

  • Type Error: Issues with data types (e.g., a string where a number is expected)
  • Unique Error: Violations of uniqueness constraints
  • Schema Error: Structural issues with the data

Example

Here’s an example of how a ValidationErrorSchema might look:

{
  "record_errors": {
    "first_name": {
      "error_message": "Field 'first_name' is required but missing",
      "error_type": "Schema Error"
    },
    "age": {
      "error_message": "Value 'thirty' is not a valid integer",
      "error_type": "Type Error"
    }
  },
  "global_errors": {
    "error_types": {
      "Unique Error": [
        {
          "error_message": "Duplicate email addresses found",
          "error_indices": [3, 7, 12],
          "error_fields": ["email"]
        }
      ]
    }
  }
}