Skip to content

fix: a site with more than 1000 nav entries could not build - #52

Merged
XtremeOwnageDotCom merged 1 commit into
mainfrom
fix/scriban-loop-limit
Sep 2, 2026
Merged

fix: a site with more than 1000 nav entries could not build#52
XtremeOwnageDotCom merged 1 commit into
mainfrom
fix/scriban-loop-limit

Conversation

@XtremeOwnageDotCom

Copy link
Copy Markdown
Contributor

What & why

A site with more than ~1000 pages in its navigation cannot be built at all:

main.html(7,3) : error : Exceeding number of iteration limit `1000` for loop statement.
main.html(49,15) : error : Exceeding number of iteration limit `1000` for loop statement.
...
fail: Build failed System.AggregateException: One or more errors occurred.

Scriban's TemplateContext defaults to LoopLimit = 1000 — a sandbox guard for templates supplied by untrusted authors. TemplateEngine constructs its context with defaults, so the theme's own nav loops (nav_active and the recursive render_nav in main.html) inherit it. Past 1000 entries the render throws and the build produces no output — it doesn't degrade, it fails.

That ceiling is well inside what this generator targets; the README's own motivation is a site with hundreds of posts. I hit it building a 1501-page corpus for an unrelated investigation.

The templates here ship with the theme rather than arriving from a site author, so the guard defends against a threat this pipeline doesn't have, while imposing a hard cap on site size. Lifted for the render context.

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Refactor / chore

Checklist

  • dotnet format Netdocs.slnx --verify-no-changes passes
  • dotnet build Netdocs.slnx -c Release succeeds
  • dotnet test Netdocs.slnx -c Release passes (512, +2 new)
  • Added/updated tests for the change
  • Updated docs under docs-site/docs/** — no documented behaviour changes; this only removes a ceiling

Verification

  • Before: a 1501-page site fails the build with the error above.
  • After: the same site builds — 1501 pages in ~11s.
  • Both new tests fail without the fix and pass with it (flat loop, and nested loops since the nav renders recursively).

Notes for reviewers

RecursiveLimit (default 100) is deliberately left alone — it bounds nav depth rather than width, real nav nesting is nowhere near it, and raising it trades a clear error for a stack overflow.

🤖 Generated with Claude Code

Scriban caps a loop at 1000 iterations by default -- a sandbox guard aimed at
templates from untrusted authors. The theme's own nav loop is subject to it, so
once a site had more than 1000 pages in its navigation the render threw
"Exceeding number of iteration limit `1000` for loop statement" and the entire
build failed. Not a degraded nav: no output at all.

Found while generating a large corpus for an unrelated investigation; a
1501-page site could not be built. That is well inside what this generator
targets -- the README's own motivation is a site with hundreds of posts.

Lift the limit for the render context. The templates here ship with the theme
rather than arriving from a site author, so the guard is protecting against a
threat that does not exist in this pipeline, at the cost of a hard ceiling on
site size.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@XtremeOwnageDotCom
XtremeOwnageDotCom merged commit 71f09ba into main Sep 2, 2026
1 check passed
@XtremeOwnageDotCom
XtremeOwnageDotCom deleted the fix/scriban-loop-limit branch September 2, 2026 03:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant