Skip to content

[AAASM-4320] 🔧 (docs): Self-host mermaid.min.js, remove unpkg CDN dependency#226

Merged
Chisanan232 merged 2 commits into
masterfrom
v0.0.1/AAASM-4320/fix/mermaid_selfhost
Jul 8, 2026
Merged

[AAASM-4320] 🔧 (docs): Self-host mermaid.min.js, remove unpkg CDN dependency#226
Chisanan232 merged 2 commits into
masterfrom
v0.0.1/AAASM-4320/fix/mermaid_selfhost

Conversation

@Chisanan232

@Chisanan232 Chisanan232 commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Description

The python-sdk docs loaded mermaid from unpkg.com/mermaid@11, which was failing with Invalid script errors on every page load (correlated with intermittent SSL failures to unpkg). Vendors mermaid@11 into the repo and points the theme at the local copy — removes a third-party CDN as a runtime SPOF and eliminates the console errors.

Type of Change

  • 🐛 Bug fix (docs page errors)
  • 🔒 Supply-chain hardening (removes CDN)
  • ⬆️ Dependency vendor

Breaking Changes

  • No.

Related Issues

Testing

  • mkdocs serve; Playwright shows 0 pageerror events on a page with a mermaid diagram, and no network requests to unpkg.com.

Checklist

  • Two small commits (vendor + wire-up).
  • Follows Gitmoji convention.

🤖 Generated with Claude Code

…endency)

The docs previously loaded mermaid at runtime from
https://unpkg.com/mermaid@11/dist/mermaid.min.js (auto-injected by
mkdocs-material when the pymdownx-superfences `mermaid` custom fence is
detected). That CDN began failing with an "Invalid script" error on every
page load (correlated with intermittent SSL failures to unpkg), rendering
no mermaid diagrams and spamming the console.

Vendor a pinned copy of mermaid@11 into the repo so the docs never depend
on a third-party CDN at read time. This commit only adds the file; the
follow-up commit rewires mkdocs to load it instead of unpkg.

Source: https://unpkg.com/mermaid@11/dist/mermaid.min.js
SHA-384: 4ffd25314749a5dd92d591ed462a1f1b786d537c4f0ab1557804355141364c9c25109495e4d5309f7d243f6f27db7f04

Refs AAASM-4320.
mkdocs-material auto-injects a mermaid runtime from
https://unpkg.com/mermaid@11/dist/mermaid.min.js the moment it sees the
pymdownx-superfences `mermaid` custom fence (configured immediately below,
lines 149-153). That CDN was throwing "Invalid script" on every page
load — no fallback, no SRI, and a third-party runtime SPOF in the docs.

Adding the self-hosted copy to `extra_javascript` makes the browser load
the pinned local blob *before* the theme's superfences integration wires
up its custom fence, so mkdocs-material treats mermaid as already-loaded
and skips the unpkg fetch. No console errors, no CDN dependency, no
supply-chain exposure at read time.

The vendored blob was added in the previous commit and is pinned to
mermaid@11.

Closes AAASM-4320.
@Chisanan232

Copy link
Copy Markdown
Contributor Author

Claude Code — 11th-sweep review

Verdict: READY to merge

  • CI: all checks green (Analyze python, Build docs, CodeQL).
  • Scope match: docs/assets/js/mermaid.min.js vendored (mermaid@11 from unpkg, sha384 4ffd2531…) and wired via extra_javascript in mkdocs.yml. Loading the vendored blob before pymdownx-superfences wires up its custom-fence handler makes mkdocs-material treat mermaid as already-loaded, so it skips the unpkg fetch entirely.
  • Side effects: none. Third-party CDN dependency removed as a runtime SPOF; no other unpkg refs remain.
  • ⚠️ Non-blocking follow-up: now that mermaid is vendored, add a supply-chain check (renovate rule / dependabot alert / periodic checksum audit) so a future mermaid CVE doesn't sit unnoticed.
  • Confidence: HIGH.

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

@Chisanan232 Chisanan232 merged commit 975a596 into master Jul 8, 2026
7 checks passed
@Chisanan232 Chisanan232 deleted the v0.0.1/AAASM-4320/fix/mermaid_selfhost 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