Add diagnostics for missing files requested by bare name (BL-16577) - #8171
Conversation
Sentry reports thousands of "Cannot Find File" events for a request whose path is the bare name "Checkbox.js". That file is not missing from the repo as the card supposed: it is a Vite chunk in output/browser. A bundle we inject into a page at the server root (Book.AddJavascriptFile) imports its sibling chunks by bare name, so they reach the server with no directory, and they should always be found under BrowserRoot. This does NOT fix that bug - we have not established why the lookup fails on the affected machines. It adds the diagnostics needed to find out, and fixes a real weakness the investigation turned up along the way. Diagnostics: when a request that carries no directory misses, the Sentry detail message now also reports BrowserRoot, whether the expected file is actually there, and the process's current working directory. Ordinary requests, which carry a directory, are unaffected. Current-directory weakness: BloomFileLocator.BrowserRoot is a relative path, so testing for a file with it resolves against the process's current working directory. Bloom does not control that directory - Windows File Explorer sets it to the folder of a double-clicked file, a shortcut's "Start in" value can override it (BL-16230), and a file dialog that does not set RestoreDirectory moves it mid-session. Two lookups did exactly that: BloomServer.LookForAFullPathToFile's browser-root preference and BloomFileLocator.GetSearchPaths. Both now use a new AbsoluteBrowserRoot, and the file dialogs no longer move the working directory. Also teaches PretendRequestInfo to parse query parameters. It always returned an empty collection, which made any request the server routes on a query parameter - such as the assetv one it adds to every JS request - impossible to test at all. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
[Claude Opus 5 (1M context)] Consulted Devin on 2026-08-06 up to commit It found no bugs. It raised one thing worth a human look — whether turning on Five further items were informational only, and I've folded the two that matter into the PR CI reported no checks on this branch, and no other review bots have commented. |
andrew-polk
left a comment
There was a problem hiding this comment.
@andrew-polk reviewed 7 files and all commit messages, and resolved 1 discussion.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on JohnThomson).
andrew-polk
left a comment
There was a problem hiding this comment.
Reviewable status:
complete! all files reviewed, all discussions resolved (waiting on JohnThomson).
What this is
Sentry issue 2699459502 ("Cannot Find File") is
dominated by requests for the bare name
Checkbox.js. The card supposed no such file exists inBloom. It does: it's a Vite chunk in
output/browser. A bundle we inject into a page at the serverroot (
Book.AddJavascriptFile) imports its sibling chunks by bare name, so they arrive at theserver with no directory — and they should always be found under
BrowserRoot.This PR does not fix that bug. I could not establish why the lookup fails on the affected
machines: the third lookup,
GetFileDistributedWithApplication, is anchored to the applicationfolder, and the absolute browser root is already a factory search path, so on a valid install the
file is found regardless of anything here. What this adds is the instrumentation needed to find
out, plus a real weakness the investigation turned up.
Changes
Diagnostics. When a request that carries no directory misses, the Sentry detail message now
also reports
BrowserRoot, whether the expected file is actually present, and the process'scurrent working directory. That distinguishes "the file is genuinely absent from that install"
from "we looked in the wrong place". Requests that carry a directory are unaffected.
The current-directory weakness.
BloomFileLocator.BrowserRootis a relative path, so testingfor a file with it resolves against the process's current working directory. Bloom doesn't control
that directory:
Program.cssays so (BL-11004);Program.NormalizeWorkingDirectory()exists;RestoreDirectorymoves it mid-session, permanently —and
BloomOpenFileDialognever set it.Two lookups depended on it:
BloomServer.LookForAFullPathToFile's browser-root preference (addedin
57893d0f1ffor BL-15894) andBloomFileLocator.GetSearchPaths. Both now use a newAbsoluteBrowserRoot, and the file dialogs no longer move the working directory.Test double.
PretendRequestInfo.GetQueryParameters()always returned an empty collection,which made any request the server routes on a query parameter — such as the
assetvone it adds toevery JS request — impossible to test at all. It now parses the query.
Risk to look at
The
GetSearchPathschange is the one with teeth: that entry previously resolved to nothingwhenever the working directory wasn't the application folder, so making it work changes lookup
precedence — the browser root now genuinely wins over the factory paths, which is what the
comment there always intended. The precedence tests in
BloomFileLocatorTestscover this and pass.Testing
BloomServerTests+BloomFileLocatorTests+BookStarterTests: 125 passed, 0 failed, stableacross repeated runs, before and after merging
master.Full-suite counts are not usable as a signal at the moment — four runs of one unchanged tree gave
135, 1, 32 and 62 failures. That is other worktrees sharing
%TEMP%plus tests that mutateprocess-wide state, not this branch. (My first attempt at a regression test here changed the
process's current directory and took out a different unrelated test on each run; it was rewritten
to assert the resolved path is rooted instead.)
Ref: https://issues.bloomlibrary.org/youtrack/issue/BL-16577
Devin review
This change is