{"record":{"id":"130028cc791311e3","repo":"invoke-ai/InvokeAI","slug":"face-ids-must-be-a-comma-separated-list-of-integer","errorCode":null,"errorMessage":"Face IDs must be a comma-separated list of integers (e.g. \"1,2,3\")","messagePattern":"Face IDs must be a comma-separated list of integers \\(e\\.g\\. \"1,2,3\"\\)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"invokeai/app/invocations/facetools.py","lineNumber":545,"sourceCode":"        default=\"\",\n        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.\",\n    )\n    minimum_confidence: float = InputField(\n        default=0.5, description=\"Minimum confidence for face detection (lower if detection is failing)\"\n    )\n    x_offset: float = InputField(default=0.0, description=\"Offset for the X-axis of the face mask\")\n    y_offset: float = InputField(default=0.0, description=\"Offset for the Y-axis of the face mask\")\n    chunk: bool = InputField(\n        default=False,\n        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.\",\n    )\n    invert_mask: bool = InputField(default=False, description=\"Toggle to invert the mask\")\n\n    @field_validator(\"face_ids\")\n    def validate_comma_separated_ints(cls, v) -> str:\n        comma_separated_ints_regex = re.compile(r\"^\\d*(,\\d+)*$\")\n        if comma_separated_ints_regex.match(v) is None:\n            raise ValueError('Face IDs must be a comma-separated list of integers (e.g. \"1,2,3\")')\n        return v\n\n    def facemask(self, context: InvocationContext, image: ImageType) -> FaceMaskResult:\n        all_faces = get_faces_list(\n            context=context,\n            image=image,\n            should_chunk=self.chunk,\n            minimum_confidence=self.minimum_confidence,\n            x_offset=self.x_offset,\n            y_offset=self.y_offset,\n            draw_mesh=True,\n        )\n\n        mask_pil = create_white_image(*image.size)\n\n        id_range = list(range(0, len(all_faces)))\n        ids_to_extract = id_range\n        if self.face_ids != \"\":","sourceCodeStart":527,"sourceCodeEnd":563,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/invocations/facetools.py#L527-L563","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Change face_ids to a strictly comma-separated integer string with no spaces or trailing comma, e.g. '1,2,3'","An empty string is allowed by the regex; use it (or omit) to disable face selection","Sanitize input in code: split on ',', strip, int(), re-join before constructing the invocation"],"exampleFix":"# before\ninvocation.face_ids = '1, 2, 3'\n# after\ninvocation.face_ids = '1,2,3'","handlingStrategy":"validation","validationCode":"import re\nif v and re.fullmatch(r'\\d*(,\\d+)*', v) is None:\n    raise ValueError(f'invalid face_ids: {v!r}')","typeGuard":"def is_comma_separated_ints(v: str) -> bool:\n    return re.fullmatch(r'\\d*(,\\d+)*', v) is not None","tryCatchPattern":"try:\n    inv = FaceMaskInvocation(face_ids=face_ids)\nexcept ValidationError as e:\n    face_ids = ','.join(s.strip() for s in face_ids.split(',') if s.strip().isdigit())\n    inv = FaceMaskInvocation(face_ids=face_ids)","preventionTips":["Build the string with ','.join(str(int(i)) for i in ids) instead of manual formatting","Never include spaces, trailing commas, or negative numbers","Sanitize user input by stripping whitespace before join"],"tags":["pydantic","validation","input-format"],"backgroundTag":"input-format-validation-failed","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}