Skip to content

Fail the build when ui/dist is missing instead of warning - #1243

Merged
gskjold merged 1 commit into
mainfrom
fix/fatal-missing-ui-dist
Aug 27, 2026
Merged

Fail the build when ui/dist is missing instead of warning#1243
gskjold merged 1 commit into
mainfrom
fix/fatal-missing-ui-dist

Conversation

@gskjold

@gskjold gskjold commented Aug 27, 2026

Copy link
Copy Markdown
Member

Change

scripts/generate_includes.py printed a warning and carried on when the UI dist was absent:

else:
    print(f"WARN: UI dist not found at '{ui_dist}' — skipping UI header generation. …")

It now exits non-zero instead. A missing UI build cannot produce working firmware, so the build should stop rather than emit a binary that looks fine.

Why the silent skip is dangerous

The generated headers in src/webserver/html/ are gitignored, so they are local artifacts that survive branch switches and PlatformIO cleans. Skipping regeneration leaves them in place, which splits the UI cache-busting scheme in half:

source value after a skipped regeneration
asset URL in index.html src/webserver/html/index_html.h (this script) whichever version last generated it
route in AmsWebServer src/generated_version.h (addversion.py, rewritten every build) current

The route answers /index-<current>.js while the HTML asks for /index-<old>.js, so the UI 404s on both .js and .css while the build reports success.

Scope

This is defensive hardening, not a fix for a live bug. In a normal clone ui/dist is tracked, so the branch is effectively unreachable — it only triggers if someone deletes the directory. It costs one line and turns a silently broken binary into a build error, but close this if you would rather not have the extra failure mode.

Verification

  • With ui/dist moved aside: exits 1 with ERROR: UI dist not found at 'ui/dist'. Run 'npm run build' in ui/ before building the firmware.
  • With ui/dist present: exits 0, generated headers unchanged, no stray files.
  • pio test unaffected: [env:native] overrides extra_scripts to pre:scripts/native_crypto.py and [env:native_config] sets none, so neither runs this script. pull-request.yml only runs the native tests.
  • Firmware workflows unaffected: build.yml and pr-build-env.yml both run npm ci && npm run build before pio run.

🤖 Generated with Claude Code

generate_includes.py printed a warning and carried on when the UI dist was
absent, leaving the previously generated headers in src/webserver/html/ in
place. Those headers are gitignored, so they survive branch switches and
cleans, and the asset URLs baked into index.html keep pointing at whichever
version generated them while addversion.py stamps the current version into
the route registered in AmsWebServer. The build then succeeds and the UI
404s on index-<version>.js and .css.

A missing UI build cannot produce a working firmware, so stop rather than
emit one that looks fine. The native test environments override
extra_scripts and never run this script, so pio test is unaffected, and both
firmware workflows run npm run build before pio run.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

🔧 PR Build Artifacts

Version: 4c7a6b9

All environments built successfully. Download the zip files:

Artifacts expire after 7 days. View workflow run

@gskjold
gskjold merged commit 2e2b046 into main Aug 27, 2026
8 checks passed
@gskjold
gskjold deleted the fix/fatal-missing-ui-dist branch August 27, 2026 10:09
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