Repository navigation
Description
Problem
just test / just test-unit / just test-rust fail on a clean checkout, before any change is made, on a test that has nothing to do with the change:
id-web crates/id-web/src/lib.rs:1141 tests::test_load_asset_urls_from_manifest
main_js should be hashed (name.hash.js): /assets/main.js
The test is not detecting a bug in the code — it is asserting that the build artifact (pkgs/id/web/dist/manifest.json) exists. On a clean checkout pkgs/id/web/dist/ contains only the tracked placeholder .gitkeep, so there is no manifest and no hashed filenames, and the assertion fails deterministically.
Evidence (origin/main 4974e7a8af9e)
-
Assets are embedded from
web/distat compile time, and the directory is empty on a clean checkout:pkgs/id/crates/id-web/src/assets.rs:24—#[folder = "../../web/dist"]pkgs/id/web/dist/.gitkeepis the only tracked file in that directory (git ls-tree origin/main -- pkgs/id/web/dist), soAssets::get("manifest.json")isNone.
-
load_asset_urls()documents and implements exactly that fallback, returning the unhashed defaults:pkgs/id/crates/id-web/src/lib.rs:509-525—let Some(manifest_data) = Assets::get("manifest.json") else { ... return AssetUrls::default(); }pkgs/id/crates/id-web/src/templates.rs:28-33—Defaultgivesmain_js: "/assets/main.js",styles_css: "/assets/styles.css".
-
The test then asserts the opposite — that the URLs must be hashed:
pkgs/id/crates/id-web/src/lib.rs:1141-1160—assert!(js_dots >= 2, "main_js should be hashed (name.hash.js): {}", urls.main_js);/assets/main.jshas one dot, so the assertion fails with its own diagnostic.
-
The failure contradicts the design intent that a clean checkout can run
cargo test.pkgs/id/build.rs:27-30says a missing/empty devweb/distis deliberately tolerated (“a dummy dist letscargo check/cargo testcompile on a clean checkout where the frontend has not been built”) and only release builds require real assets (:31-41). -
The documented dev recipes never build the frontend first, so they inherit the failure:
pkgs/id/justfile:227-228—test-rust: cargo nextest run --all-featurespkgs/id/justfile:239—test: test-rust test-web-unit test-web-typecheckpkgs/id/justfile:293-294—test-unit: cargo nextest run --all-features --libpkgs/id/AGENTS.md:109listsjust testas “All fast tests”, with no built-assets prerequisite.
-
Observed twice, independently, already tolerated as noise:
- issue-sweep run 2026-11-16T04:43Z (backlog, item 1):
cargo test -p id-web --lib→ “676 passed + 1 pre-existing env failure (test_load_asset_urls_from_manifest, needs built web assets)”. - That lane recorded it as an accepted environment failure rather than a defect, which is exactly the tolerance this issue asks to remove.
- issue-sweep run 2026-11-16T04:43Z (backlog, item 1):
crates/id-web is in the workspace default-members (pkgs/id/Cargo.toml:38-50), so every cargo nextest run --all-features hits this test; the nix test venues pass only because their shared derivation runs (cd web && bun run build) before just <check> (pkgs/id/flake.nix:180-240), which is precisely why nothing catches this locally.
Repro
git clone https://github.com/developing-today/code && cd code/pkgs/id
ls -A web/dist # .gitkeep only
just test-unit # or: cargo test -p id-web --lib test_load_asset_urls_from_manifest
# => FAIL id-web ... test_load_asset_urls_from_manifest
# main_js should be hashed (name.hash.js): /assets/main.jsNo web/dist build, no bun, no network: the failure is deterministic and requires nothing but a fresh clone.
Why it matters
- Every fresh clone, worktree, and contributor's first
just testis red before touching anything, and the failure is in a crate unrelated to the change being tested — the classic path to “known red test” blindness where a realid-webregression hides behind the expected one. - It also breaks the fast local loop the recipes exist for:
just test-unitis advertised as “unit tests only (fast)”, yet it depends on a Bun frontend build that those recipes do not run. - The test does not verify what it looks like it verifies. It asserts that a build artifact exists, not that
load_asset_urlsmaps a manifest to URLs correctly; the transformation itself (main.js→main.<hash>.js) has no direct coverage.
Fix shape
Preferred: make the test independent of the build tree.
- Extract the pure mapping so it can be tested directly, e.g.
fn asset_urls_from_manifest(manifest: &serde_json::Value) -> AssetUrls(or from&str), withload_asset_urls()reduced toAssets::get("manifest.json")→ parse →asset_urls_from_manifest. - Test the mapping with an inline fixture manifest (
{"main.js":"main.deadbeef.js","styles.css":"styles.deadbeef.css"}) and assert the/assets/prefix and hashed name; test the documented fallback separately (absent/invalid manifest →AssetUrls::default()), and keep the “compiles with an emptyweb/dist” property asserted. - Optionally keep one build-artifact assertion for the release variant in a check that actually builds the frontend, rather than in the unit suite.
Acceptable alternative, if the extraction is not wanted: have just test* recipes depend on the web build (e.g. test-unit: web), but that reintroduces the Bun dependency into the “fast” loop, so the extraction is preferred.
Acceptance criteria
-
cargo test -p id-web --lib(andjust test-unit/just test-rust) passes on a clean clone with an emptypkgs/id/web/dist(only.gitkeep), with no Bun build. - A manifest-to-URLs mapping test exists that covers the hashed-name transformation and the
/assets/prefix from a fixture manifest. - The missing-manifest fallback remains covered (defaults returned, no panic), matching
load_asset_urls' documented behaviour andpkgs/id/build.rs's clean-checkout intent. - Nothing in the release build path is weakened: a release build without real frontend assets still fails as
pkgs/id/build.rs:31-41requires.
Related
- id: release web-asset guard counts web/dist/.gitkeep as built assets, shipping a 404 web UI (PR #9340 Codex P2) #9616 (open) — the release web-asset guard counts
web/dist/.gitkeepas “built”, so a.gitkeep-only tree can ship a 404 web UI. Same placeholder file, different code path (release guard, not tests); this issue does not supersede it. - fix(id-web): hold web file names to the canonical-name rule #10590 (merged) — the run whose comment first recorded this failure as a “pre-existing env failure”.
Activity
developing-today commentedon Nov 16, 2026
CODE-3854
fix(id-web): tolerate missing web/dist manifest in asset-url test (#1…