{"record":{"id":"55a4b7bd8add968b","repo":"twentyhq/twenty","slug":"found-len-overflow-errors-overflow-error-s-and","errorCode":null,"errorMessage":"Found {len(overflow_errors)} overflow error(s) and {len(warnings)} warning(s)","messagePattern":"Found (.+?) overflow error\\(s\\) and (.+?) warning\\(s\\)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"packages/twenty-server/src/engine/core-modules/code-interpreter/sandbox-scripts/pptx/replace.py","lineNumber":341,"sourceCode":"    for slide_key, shapes_dict in updated_inventory.items():\n        for shape_key, shape_data in shapes_dict.items():\n            if shape_data.warnings:\n                for warning in shape_data.warnings:\n                    warnings.append(f\"{slide_key}/{shape_key}: {warning}\")\n\n    # Fail if there are any issues\n    if overflow_errors or warnings:\n        print(\"\\nERROR: Issues detected in replacement output:\")\n        if overflow_errors:\n            print(\"\\nText overflow worsened:\")\n            for error in overflow_errors:\n                print(f\"  - {error}\")\n        if warnings:\n            print(\"\\nFormatting warnings:\")\n            for warning in warnings:\n                print(f\"  - {warning}\")\n        print(\"\\nPlease fix these issues before saving.\")\n        raise ValueError(\n            f\"Found {len(overflow_errors)} overflow error(s) and {len(warnings)} warning(s)\"\n        )\n\n    # Save the presentation\n    prs.save(output_file)\n\n    # Report results\n    print(f\"Saved updated presentation to: {output_file}\")\n    print(f\"Processed {len(prs.slides)} slides\")\n    print(f\"  - Shapes processed: {shapes_processed}\")\n    print(f\"  - Shapes cleared: {shapes_cleared}\")\n    print(f\"  - Shapes replaced: {shapes_replaced}\")\n\n\ndef main():\n    \"\"\"Main entry point for command-line usage.\"\"\"\n    if len(sys.argv) != 4:\n        print(__doc__)","sourceCodeStart":323,"sourceCodeEnd":359,"githubUrl":"https://github.com/twentyhq/twenty/blob/1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6/packages/twenty-server/src/engine/core-modules/code-interpreter/sandbox-scripts/pptx/replace.py#L323-L359","documentation":"Raised near the end of apply_replacements, after all text has been swapped and a post-pass has measured text overflow on each shape. If the replacement text made any shape overflow worse (overflow_errors) or produced formatting warnings, the function refuses to save the deck and throws with both counts. This protects users from silently shipping a deck with truncated or mis-formatted text.","triggerScenarios":"Replacement strings are longer than the original and push text past the shape's auto-fit boundary (overflow_errors), or the replacement introduces formatting inconsistencies the checker flags (warnings) — e.g. mixed runs, lost bold, font mismatch. The throw happens after mutation but before prs.save().","commonSituations":"LLM-generated replacement text that is verbose and overflows fixed-size text boxes; replacing a short placeholder with a paragraph; substituting text in a shape whose auto-fit is set to none. The per-error and per-warning lists are printed to stdout immediately before the throw.","solutions":["Read the printed overflow list — each entry names the slide/shape and how much text exceeds the box.","Shorten the offending replacement strings, or enable auto-fit / shrink-text on those shapes in the source deck.","Split long content across multiple shapes or slides rather than overfilling one box.","If a warning is acceptable for your use case, pre-size the shape or adjust the font in the template so the post-pass no longer flags it."],"exampleFix":"# before — long replacement overflows the title shape\n{\"slide-1\": {\"title\": \"A very long replacement string that does not fit the title placeholder\"}}\n# after — concise text that fits, or move detail to the body shape\n{\"slide-1\": {\"title\": \"Q3 Results\", \"body\": \"A very long replacement string that does not fit the title placeholder\"}}","handlingStrategy":"validation","validationCode":"# Pre-check replacement string lengths against the original where shape box sizes are known.\ndef flag_long_replacements(inventory: dict, replacements: dict, ratio: float = 1.5) -> list[str]:\n    warnings = []\n    for slide_key, shapes in replacements.items():\n        for shape_key, new_text in shapes.items():\n            orig = inventory.get(slide_key, {}).get(shape_key)\n            if isinstance(orig, str) and isinstance(new_text, str) and len(new_text) > len(orig) * ratio:\n                warnings.append(f'{slide_key}.{shape_key}: {len(orig)} -> {len(new_text)} chars')\n    return warnings","typeGuard":"def is_safe_replacement_length(original: str, replacement: str, max_ratio: float = 1.3) -> bool:\n    return len(replacement) <= max(20, len(original) * max_ratio)","tryCatchPattern":"try:\n    apply_replacements(pptx, replacements_json, output)\nexcept ValueError as e:\n    if 'overflow error' in str(e):\n        # overflow list already printed; shorten replacements or enable autofit and retry\n        enable_autofit_on_flagged_shapes(pptx, output)  # placeholder for repair step\n        raise SystemExit('Overflow detected. Shorten replacement text or enable autofit; see list above.')\n    raise","preventionTips":["Keep replacement strings close to the original length; move long content to dedicated body shapes.","Enable shrink-text-to-fit on small fixed shapes in the source template.","Run a dry measurement pass (the same overflow checker) on the source before authoring replacements."],"tags":["python","pptx","code-interpreter","validation","text-overflow"],"backgroundTag":null,"analyzedSha":"1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6","analyzedAt":"2026-08-12T15:37:27.593Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}