{"record":{"id":"0ebf3e7748760fcf","repo":"ATH-MaaS/Pixelle-Video","slug":"no-image-paths-provided","errorCode":null,"errorMessage":"No image paths provided","messagePattern":"No image paths provided","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"pixelle_video/services/api_services/image_processor.py","lineNumber":114,"sourceCode":"        left_box = (0, 0, mid_col, self.height)\n        right_box = (mid_col, 0, self.width, self.height)\n        left_image = self.image.crop(left_box)\n        right_image = self.image.crop(right_box)\n\n        save_dir, filename = os.path.split(self.image_path)\n        base, extension = os.path.splitext(filename)\n\n        left_image_path = os.path.join(save_dir, base + '_front' + extension)\n        right_image_path = os.path.join(save_dir, base + '_back' + extension)\n        left_image.save(left_image_path)\n        right_image.save(right_image_path)\n\n        return left_image_path, right_image_path\n    \n    def stitch_images(self, image_paths, output_path):\n        \"\"\"拼接多张图片\"\"\"\n        if not image_paths:\n            raise ValueError(\"No image paths provided\")\n        sample_image = Image.open(image_paths[0])\n        single_width, single_height = sample_image.size\n        num_images = len(image_paths)\n        total_desired_width = single_width\n        total_current_width = single_width * num_images\n        total_width_to_cut = max(0, total_current_width - total_desired_width)\n        width_to_cut_per_image = total_width_to_cut // num_images\n        stitched_image = Image.new('RGB', (total_desired_width, single_height), \"white\")\n        current_x = 0\n        \n        for path in image_paths:\n            image = Image.open(path)\n            if width_to_cut_per_image > 0:\n                left_margin = width_to_cut_per_image // 2\n                right_margin = image.width - width_to_cut_per_image + left_margin\n                image = image.crop((left_margin, 0, right_margin, image.height))\n            stitched_image.paste(image, (current_x, 0))\n            current_x += image.width","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/ATH-MaaS/Pixelle-Video/blob/848b054e4fae40dabc62ec58e960b573e83793ac/pixelle_video/services/api_services/image_processor.py#L96-L132","documentation":"stitch_images merges multiple split images back into one and raises ValueError when image_paths is empty or None. It is a guard: opening image_paths[0] would otherwise crash with an opaque IndexError.","triggerScenarios":"Calling stitch_images([]), stitch_images(None), or with a list of paths that a previous collection step (e.g. split/glob) produced zero results for.","commonSituations":"Glob/directory scan returned no files (wrong directory or extension filter), all split operations failed earlier leaving an empty list, caller passes an empty list after filtering nonexistent files.","solutions":["Ensure the caller collects the actual saved image paths before calling stitch_images.","Check the source directory contains the expected split images (correct path and extensions).","Guard the call site with a length check and skip stitching gracefully when nothing to merge."],"exampleFix":"// before\nprocessor.stitch_images(paths, out)\n\n// after\npaths = sorted(glob.glob(os.path.join(split_dir, '*.png')))\nif paths:\n    processor.stitch_images(paths, out)","handlingStrategy":"validation","validationCode":"if not image_paths:\n    raise ValueError(\"stitch_images called with no paths\")\nmissing = [p for p in image_paths if not os.path.exists(p)]\nassert not missing, f\"missing files: {missing}\"","typeGuard":"def is_valid_path_list(paths) -> bool:\n    return isinstance(paths, (list, tuple)) and len(paths) > 0 and all(\n        isinstance(p, str) and os.path.exists(p) for p in paths)","tryCatchPattern":"try:\n    processor.stitch_images(paths, out)\nexcept ValueError as e:\n    logging.warning(f\"Nothing to stitch: {e}\")  # skip stitching step","preventionTips":["Always collect saved file paths from the split step rather than re-globbing","Check directory contents and extension filters before merging","Skip stitching gracefully when the list is empty after filtering","Use sorted stable ordering so partial results are handled predictably"],"tags":["image-processing","empty-input","valueerror"],"backgroundTag":"empty-input-validation","analyzedSha":"848b054e4fae40dabc62ec58e960b573e83793ac","analyzedAt":"2026-08-30T03:24:41.468Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}