[AAASM-4317] 🐛 (docs/theme): Guard inline new URL() against empty template value#227
Merged
Merged
Conversation
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>
Contributor
Author
Claude Code — 11th-sweep reviewVerdict: READY to merge
Reviewed by Claude Code as part of the AAASM-4307 fix wave. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
https://docs.agent-assembly.com/python-sdk/pre-release/was throwing an uncaughtTypeError: Failed to construct 'URL': Invalid URLfrom an inline<script>at line 185 col 88 of the rendered HTML on every page load. The call site is Material's stockpartials/javascripts/outdated.html, which runsnew URL("{{ base_url }}")with no base argument.base_urlrenders 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 passeslocationas the base, anddocs/_overrides/main.htmlrenders our own version-warning banner script that constructs two more URLs. This PR adds defense-in-depthtry/catchguards around everynew URL(...)call in both files so any future template regression that rendersbase_urlas an unparseable value silently no-ops the banner instead of surfacing a page-loadTypeError.Type of Change
Breaking Changes
try/catcharound three inlinenew URL(...)calls is idempotent. Success path is byte-identical to today; failure path replaces an uncaughtTypeErrorwith a silent no-op (the static fallback copy already rendered in the HTML remains visible).Related Issues
location-base fix)Verification (Playwright)
Local
mkdocs serveonhttp://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 URLfrom inline script at line 185 col 88 on every page load.After this PR:
/python-sdk/) — 0pageerrorevents. Only console errors are 2 networkversions.json404s (expected — mkdocs serve doesn't have mike'sversions.json; live site has it)./python-sdk/guides/, wherebase_urlrenders as..) — 0pageerrorevents. 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
🐛 (scope): ...).--no-verify, no force-push..claude/CLAUDE.mdgotcha).pageerrorevents on landing + nested page).🤖 Generated with Claude Code