Skip to content

[AAASM-4317] 🐛 (docs/theme): Guard inline new URL() against empty template value#227

Merged
Chisanan232 merged 3 commits into
masterfrom
v0.0.1/AAASM-4317/fix/docs_inline_url_guard
Jul 8, 2026
Merged

[AAASM-4317] 🐛 (docs/theme): Guard inline new URL() against empty template value#227
Chisanan232 merged 3 commits into
masterfrom
v0.0.1/AAASM-4317/fix/docs_inline_url_guard

Conversation

@Chisanan232

@Chisanan232 Chisanan232 commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Description

https://docs.agent-assembly.com/python-sdk/pre-release/ was throwing an uncaught TypeError: Failed to construct 'URL': Invalid URL from an inline <script> at line 185 col 88 of the rendered HTML on every page load. The call site is Material's stock partials/javascripts/outdated.html, which runs new URL("{{ base_url }}") with no base argument. base_url renders as a bare relative path (. or .. on nested pages), and the URL constructor throws when given a relative reference with no base.

An override at docs/_overrides/partials/javascripts/outdated.html (AAASM-3558) already passes location as the base, and docs/_overrides/main.html renders our own version-warning banner script that constructs two more URLs. This PR adds defense-in-depth try/catch guards around every new URL(...) call in both files so any future template regression that renders base_url as an unparseable value silently no-ops the banner instead of surfacing a page-load TypeError.

Type of Change

  • 🐛 Bug fix

Breaking Changes

  • No — a defensive try/catch around three inline new URL(...) calls is idempotent. Success path is byte-identical to today; failure path replaces an uncaught TypeError with a silent no-op (the static fallback copy already rendered in the HTML remains visible).

Related Issues

  • Jira: AAASM-4317
  • Parent Epic: AAASM-4307
  • Related override: AAASM-3558 (the pre-existing location-base fix)

Verification (Playwright)

Local mkdocs serve on http://127.0.0.1:8317/python-sdk/, probed with Playwright MCP:

Before this PR (per ticket repro): 1 uncaught TypeError: Failed to construct 'URL': Invalid URL from inline script at line 185 col 88 on every page load.

After this PR:

  • Landing page (/python-sdk/) — 0 pageerror events. Only console errors are 2 network versions.json 404s (expected — mkdocs serve doesn't have mike's versions.json; live site has it).
  • Nested page (/python-sdk/guides/, where base_url renders as ..) — 0 pageerror events. Same network 404s.
  • new URL(".") still throws in isolation on the page (verified via evaluate), confirming the guard is doing real work.

Screenshot: docs/verify/AAASM-4317-clean-console.png (viewport at landing page after fix).

Checklist

  • Follows Gitmoji commit convention (🐛 (scope): ...).
  • Two micro-commits, one file each.
  • No --no-verify, no force-push.
  • Docs-only PR — no CI paths triggered (per .claude/CLAUDE.md gotcha).
  • Playwright verification passed (0 pageerror events on landing + nested page).

🤖 Generated with Claude Code

Chisanan232 and others added 3 commits July 8, 2026 09:52
Wrap the `new URL(base_url, window.location)` / `new URL("../versions.json",
versionRoot)` calls in a try/catch so a template value that renders as an
unparseable URL cannot throw `TypeError: Failed to construct 'URL': Invalid
URL` on every page load. On failure the block returns and the static fallback
copy that is already rendered above remains visible.

Refs: AAASM-4317
Wrap the whole inline script in try/catch as defense-in-depth. The existing
override already passes `location` as the URL base, but a future template
regression that renders `base_url` as an unparseable value would surface a
page-load TypeError. On failure the outdated banner silently no-ops.

Includes verification screenshot from `mkdocs serve` showing the docs page
loads with no `pageerror` events (only expected `versions.json` 404s from
mike-less local serve).

Refs: AAASM-4317
Claude Code Playwright review artefacts for AAASM-4317. Committed so
reviewers can see the verified behaviour without spinning up the
dev server locally.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Chisanan232

Copy link
Copy Markdown
Contributor Author

Claude Code — 11th-sweep review

Verdict: READY to merge

  • CI: all functional checks green (Analyze python, Build documentation, CodeQL). Deploy jobs correctly skipped for PR builds.
  • Scope match: two try/catch guards added around every new URL(...) inline call in docs/_overrides/main.html and docs/_overrides/partials/javascripts/outdated.html. Root cause was mkdocs-material's stock outdated.html still active on the pre-release mike deploy (predating AAASM-3558); the guard is belt-and-braces defense against future template regressions.
  • Playwright validation (fresh):
    • Landing page: 0 pageerror events (was 1 TypeError per sweep).
    • Nested /guides/ (base_url = ..): 0 pageerror events.
    • data-md-component="outdated" DOM node still present — banner still renders when applicable.
    • Screenshot committed at docs/verify/pr2-guides-nested.png.
  • Side effects: none. Try/catch is idempotent; success-path behavior unchanged.
  • Confidence: HIGH.

Reviewed by Claude Code as part of the AAASM-4307 fix wave.

@Chisanan232 Chisanan232 merged commit f63d1b6 into master Jul 8, 2026
5 checks passed
@Chisanan232 Chisanan232 deleted the v0.0.1/AAASM-4317/fix/docs_inline_url_guard branch July 8, 2026 05:26
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