twentyhq/twenty · error · ValueError

Found {len(overflow_errors)} overflow error(s) and {len(warn

Error message

Found {len(overflow_errors)} overflow error(s) and {len(warnings)} warning(s)

What it means

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.

Source

Thrown at packages/twenty-server/src/engine/core-modules/code-interpreter/sandbox-scripts/pptx/replace.py:341

    for slide_key, shapes_dict in updated_inventory.items():
        for shape_key, shape_data in shapes_dict.items():
            if shape_data.warnings:
                for warning in shape_data.warnings:
                    warnings.append(f"{slide_key}/{shape_key}: {warning}")

    # Fail if there are any issues
    if overflow_errors or warnings:
        print("\nERROR: Issues detected in replacement output:")
        if overflow_errors:
            print("\nText overflow worsened:")
            for error in overflow_errors:
                print(f"  - {error}")
        if warnings:
            print("\nFormatting warnings:")
            for warning in warnings:
                print(f"  - {warning}")
        print("\nPlease fix these issues before saving.")
        raise ValueError(
            f"Found {len(overflow_errors)} overflow error(s) and {len(warnings)} warning(s)"
        )

    # Save the presentation
    prs.save(output_file)

    # Report results
    print(f"Saved updated presentation to: {output_file}")
    print(f"Processed {len(prs.slides)} slides")
    print(f"  - Shapes processed: {shapes_processed}")
    print(f"  - Shapes cleared: {shapes_cleared}")
    print(f"  - Shapes replaced: {shapes_replaced}")


def main():
    """Main entry point for command-line usage."""
    if len(sys.argv) != 4:
        print(__doc__)

View on GitHub (pinned to 1f5dd2bbd2)

Solutions

  1. Read the printed overflow list — each entry names the slide/shape and how much text exceeds the box.
  2. Shorten the offending replacement strings, or enable auto-fit / shrink-text on those shapes in the source deck.
  3. Split long content across multiple shapes or slides rather than overfilling one box.
  4. 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.

Example fix

# before — long replacement overflows the title shape
{"slide-1": {"title": "A very long replacement string that does not fit the title placeholder"}}
# after — concise text that fits, or move detail to the body shape
{"slide-1": {"title": "Q3 Results", "body": "A very long replacement string that does not fit the title placeholder"}}
Defensive patterns

Strategy: validation

Validate before calling

# Pre-check replacement string lengths against the original where shape box sizes are known.
def flag_long_replacements(inventory: dict, replacements: dict, ratio: float = 1.5) -> list[str]:
    warnings = []
    for slide_key, shapes in replacements.items():
        for shape_key, new_text in shapes.items():
            orig = inventory.get(slide_key, {}).get(shape_key)
            if isinstance(orig, str) and isinstance(new_text, str) and len(new_text) > len(orig) * ratio:
                warnings.append(f'{slide_key}.{shape_key}: {len(orig)} -> {len(new_text)} chars')
    return warnings

Type guard

def is_safe_replacement_length(original: str, replacement: str, max_ratio: float = 1.3) -> bool:
    return len(replacement) <= max(20, len(original) * max_ratio)

Try / catch

try:
    apply_replacements(pptx, replacements_json, output)
except ValueError as e:
    if 'overflow error' in str(e):
        # overflow list already printed; shorten replacements or enable autofit and retry
        enable_autofit_on_flagged_shapes(pptx, output)  # placeholder for repair step
        raise SystemExit('Overflow detected. Shorten replacement text or enable autofit; see list above.')
    raise

Prevention

When it happens

Trigger: 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().

Common situations: 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.

Related errors


AI-assisted analysis of twentyhq/twenty@1f5dd2bbd2 (2026-08-12). Data as JSON: /api/errors/55a4b7bd8add968b. Report an issue: GitHub.