Skip to content

[Bug]: nonlocal truncated declared but never assigned in _emit_rich_line — PDF overflow may go undetected #122

Open

Description

@MaheshAspirant

Summary

In generation/pdf_renderer.py, the nested function _emit_rich_line declares
nonlocal truncated but never assigns to it, making the declaration a no-op and
potentially leaving PDF content overflow undetected.

Steps to reproduce

  1. Open backend/generation/pdf_renderer.py
  2. Find the nested function _emit_rich_line (around line 414)
  3. Note nonlocal truncated at line 419 — no assignment to truncated exists in the function
  4. Run: python -m pyflakes generation/pdf_renderer.py
    Output confirms the warning at line 419

Expected behavior

Either:

  • _emit_rich_line sets truncated = True when rendered content exceeds page bounds, or
  • The nonlocal truncated declaration is removed if the function intentionally only reads the flag

Without one of these fixes, oversized PDF content processed by this function may not
trigger the truncation guard in the outer scope.

OS / app version

OS: Windows 11, App version: JustHireMe v0.1

Activity

  1. vasu-devs commented on Jul 18, 2026

    @vasu-devs
    Owner

    Fixed on dev (commit 9548219), and your report was pointing at something real beyond the lint: emit() pre-measures line height with plain-font widths, but _emit_rich_line renders inline-bold runs, which are wider - so a bold-heavy line could overflow the page without tripping the truncation guard. Two changes: rich lines are now measured as bold (conservative pre-check), and _emit_rich_line flags truncated post-render if the cursor passed the bottom margin, which feeds the existing rebuild-at-smaller-scale loop. The nonlocal is now load-bearing. Ships in the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions