{"record":{"id":"c1e7377d557c0530","repo":"apache/beam","slug":"one-or-more-of-the-specified-parts-could-not-be-found","errorCode":null,"errorMessage":"One or more of the specified parts could not be found","messagePattern":"One or more of the specified parts could not be found","errorType":"http","errorClass":"S3ClientError","httpStatus":400,"severity":"error","filePath":"sdks/python/apache_beam/io/aws/clients/s3/fake_client.py","lineNumber":213,"sourceCode":"    if upload_id not in self.multipart_uploads:\n      raise messages.S3ClientError('The specified upload does not exist', 404)\n\n    self.multipart_uploads[upload_id][part_number] = request.bytes\n\n    etag = '\"%s\"' % ('x' * 32)\n    return messages.UploadPartResponse(etag, part_number)\n\n  def complete_multipart_upload(self, request):\n    MIN_PART_SIZE = 5 * 2**10  # 5 KiB\n\n    parts_received = self.multipart_uploads[request.upload_id]\n\n    # Check that we got all the parts that they intended to send\n    part_numbers_to_confirm = set(part['PartNumber'] for part in request.parts)\n\n    # Make sure all the expected parts are present\n    if part_numbers_to_confirm != set(parts_received.keys()):\n      raise messages.S3ClientError(\n          'One or more of the specified parts could not be found', 400)\n\n    # Sort by part number\n    sorted_parts = sorted(parts_received.items(), key=lambda pair: pair[0])\n    sorted_bytes = [bytes_ for (_, bytes_) in sorted_parts]\n\n    # Make sure that the parts aren't too small (except the last part)\n    part_sizes = [len(bytes_) for bytes_ in sorted_bytes]\n    if any(size < MIN_PART_SIZE for size in part_sizes[:-1]):\n      e_message = \"\"\"\n      All parts but the last must be larger than %d bytes\n      \"\"\" % MIN_PART_SIZE\n      raise messages.S3ClientError(e_message, 400)\n\n    # String together all bytes for the given upload\n    final_contents = b''.join(sorted_bytes)\n\n    # Create FakeFile object","sourceCodeStart":195,"sourceCodeEnd":231,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/io/aws/clients/s3/fake_client.py#L195-L231","documentation":"FakeS3Client.complete_multipart_upload raises S3ClientError('One or more of the specified parts could not be found', 400) when the part numbers listed in the complete request don't exactly match the parts actually received via upload_part. It mirrors the InvalidPart error from real S3.","triggerScenarios":"Completing an upload where request.parts references part numbers never uploaded (or vice versa): skipped a part, uploaded an extra part, or duplicate part numbers in the request.","commonSituations":"Retries that re-uploaded some parts and the completed list diverged; loop skipping an index; building the parts list from metadata out of sync with what was actually sent.","solutions":["Make the completed parts list exactly match the (part_number, etag) pairs returned by each upload_part call","Track uploaded part numbers in a set and pass that to the complete request","Remove duplicates and fill in any missing part numbers before completing","Log/compare requested vs received part numbers when this error occurs in tests"],"exampleFix":"// before\nfake_client.complete_multipart_upload(messages.CompleteMultipartUploadRequest(upload_id, [{'PartNumber': 1}, {'PartNumber': 3}]))\n// after\nparts = [{'PartNumber': n, 'ETag': etag} for n, etag in uploaded_parts.items()]\nfake_client.complete_multipart_upload(messages.CompleteMultipartUploadRequest(upload_id, parts))","handlingStrategy":"validation","validationCode":"received = set(fake_client.multipart_uploads[upload_id].keys())\nrequested = {p['PartNumber'] for p in parts}\nassert requested == received, f'mismatch: missing={received-requested}, extra={requested-received}'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Build the complete request from the exact responses of upload_part calls","Record (part_number, etag) pairs as you upload","Deduplicate part numbers and retry failed parts before completing","Compare requested vs received sets in test assertions"],"tags":["aws","s3","multipart-upload"],"backgroundTag":"schema-validation-failed","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}