invoke-ai/InvokeAI · error · ValueError

Face IDs must be a comma-separated list of integers (e.g. "1

Error message

Face IDs must be a comma-separated list of integers (e.g. "1,2,3")

What it means

FaceTools face_ids input must be a comma-separated list of non-negative integers matching the regex ^\d*(,\d+)*$. Pydantic's field_validator raises this ValueError during model validation when the string does not match, e.g. spaces, trailing commas, letters, or negative numbers.

Source

Thrown at invokeai/app/invocations/facetools.py:545

        default="",
        description="Comma-separated list of face ids to mask eg '0,2,7'. Numbered from 0. Leave empty to mask all. Find face IDs with FaceIdentifier node.",
    )
    minimum_confidence: float = InputField(
        default=0.5, description="Minimum confidence for face detection (lower if detection is failing)"
    )
    x_offset: float = InputField(default=0.0, description="Offset for the X-axis of the face mask")
    y_offset: float = InputField(default=0.0, description="Offset for the Y-axis of the face mask")
    chunk: bool = InputField(
        default=False,
        description="Whether to bypass full image face detection and default to image chunking. Chunking will occur if no faces are found in the full image.",
    )
    invert_mask: bool = InputField(default=False, description="Toggle to invert the mask")

    @field_validator("face_ids")
    def validate_comma_separated_ints(cls, v) -> str:
        comma_separated_ints_regex = re.compile(r"^\d*(,\d+)*$")
        if comma_separated_ints_regex.match(v) is None:
            raise ValueError('Face IDs must be a comma-separated list of integers (e.g. "1,2,3")')
        return v

    def facemask(self, context: InvocationContext, image: ImageType) -> FaceMaskResult:
        all_faces = get_faces_list(
            context=context,
            image=image,
            should_chunk=self.chunk,
            minimum_confidence=self.minimum_confidence,
            x_offset=self.x_offset,
            y_offset=self.y_offset,
            draw_mesh=True,
        )

        mask_pil = create_white_image(*image.size)

        id_range = list(range(0, len(all_faces)))
        ids_to_extract = id_range
        if self.face_ids != "":

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Change face_ids to a strictly comma-separated integer string with no spaces or trailing comma, e.g. '1,2,3'
  2. An empty string is allowed by the regex; use it (or omit) to disable face selection
  3. Sanitize input in code: split on ',', strip, int(), re-join before constructing the invocation

Example fix

# before
invocation.face_ids = '1, 2, 3'
# after
invocation.face_ids = '1,2,3'
Defensive patterns

Strategy: validation

Validate before calling

import re
if v and re.fullmatch(r'\d*(,\d+)*', v) is None:
    raise ValueError(f'invalid face_ids: {v!r}')

Type guard

def is_comma_separated_ints(v: str) -> bool:
    return re.fullmatch(r'\d*(,\d+)*', v) is not None

Try / catch

try:
    inv = FaceMaskInvocation(face_ids=face_ids)
except ValidationError as e:
    face_ids = ','.join(s.strip() for s in face_ids.split(',') if s.strip().isdigit())
    inv = FaceMaskInvocation(face_ids=face_ids)

Prevention

When it happens

Trigger: Providing face_ids values like '1, 2' (spaces), '1,2,', '-1', 'a,b', '1+2' to a FaceMaskInvocation; the validator runs whenever the field is populated.

Common situations: Typing human-friendly input with spaces after commas into the node form; generating IDs from code with join(',') on non-integer values; pasting UUIDs or face names instead of numeric indices.

Related errors


AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29). Data as JSON: /api/errors/130028cc791311e3. Report an issue: GitHub.