fix(transcription): give the model-registry JSON import its type attribute - #1933
Merged
Conversation
…ibute policyRules.ts gained a modelRegistryData.json import in 1.9.1 (#1836) without `with { type: "json" }`. ipcHandlers.js reaches that module through Electron's bare Node ESM loader, which rejects attribute-less JSON imports, so proxy-xai-transcription, retry-transcription and transcribe-audio-file-byok threw ERR_IMPORT_ATTRIBUTE_MISSING in packaged builds on every platform. The existing tests import the same module but run under tsx, which resolves those imports anyway, so they passed. The new test imports each main-process ESM entry in a child process with no loader hooks, matching what the packaged app actually does. Prepares 1.9.2. Fixes #1908
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.
Three transcription paths have thrown
needs an import attribute of "type: json"in packaged builds since 1.9.1, on every platform. One missing import attribute. Also prepares 1.9.2.Fixes #1908
Root cause
policyRules.tsgainedimport modelRegistryData from "../models/modelRegistryData.json"in 1.9.1 via #1836.ipcHandlers.jsreaches that module through Electron's bare Node ESM loader, which requireswith { type: "json" }on JSON imports. Reproducible straight from the source tree, no packaging needed:voiceSurfaceGeometry.mjs:1already writes it the correct way, so the fix matches what is already in the tree.Blast radius
I walked the main-process ESM graph: 7 modules, exactly one bad JSON import.
ipcHandlers.jsis the only main-process file that imports raw.ts, and it does so from three handlers:proxy-xai-transcriptionretry-transcriptiontranscribe-audio-file-byokOrdinary dictation is unaffected, which matches the reports.
Narrower than the issue thread suggests.
audioManager.jsanddiscardedRecording.jsare renderer modules (imported byControlPanel.tsxanduseAudioRecording.js), so Vite inlines their JSON.languageSupport.ts,prompts.tsandtranslations.tsare not in the main-process graph either —i18nMain.jsbypassesprompts.tsandrequire()s the raw per-locale JSON.ModelRegistry.tscarries the same shape but every importer uses an extensionless specifier, which Node's resolver does not resolve, so it is latent rather than reachable. Only the one site is fixed here.Why the existing tests passed
test/helpers/transcriptionRoute.test.jsalready imports the exact module that fails in production, 13 tests deep. The suite runs undernode --import tsx, and tsx resolves attribute-less JSON imports:So adding another ordinary test would not have helped. The new test spawns each main-process ESM entry in a child process with
NODE_OPTIONSstripped, so it exercises the loader the packaged app actually uses. Verified red-first: it fails without the one-line fix and passes with it.eslint.config.js:8also ignoreshelpers/**andutils/**, so no static rule could have caught this either.1.9.2
Bumps the version and moves the changelog's Unreleased entries into a
[1.9.2]section covering everything since 1.9.1:with { type: "json" }(policyRules.ts / ModelRegistry.ts) #1908 — this fixVerification
Ran against a freshly installed
node_modules(my local copy was stale, which had been masking two unrelated failures):npm run typecheck— cleannpm run lint— clean, zero warningsnpm run format— no changes to makenpm test— 3314 tests, 0 failures, 185 skips (the usual local better-sqlite3 ABI skips)npm run build:renderer— buildsPrettier is clean on all touched files. Worth noting separately: the repo's
formatscript runs Prettier from insidesrc, sotest/**is never covered by it — 38 test files are currently unformatted. Identical count before and after this change, so I left them alone rather than burying a release fix in reformatting noise.Follow-ups, not in this PR
policyValidation.js:35rejects forward-compatible policies. It validates server-sent provider ids against the client's own bundled registry, so a 1.9.0 client receivinggeminiinallowedByokProvidersfailsisValidPolicyShape,workspacePolicyManager.js:288throws "Malformed policy response", andpolicyRules.ts:24fails closed — a personal account gets a locked model selector and a "Managed by your organization" badge. The same file already documents the right pattern forrequiredLocalModelsat lines 50-53, and both behaviors are pinned by contradictory tests (policyValidation.test.js:79accepts unknown model ids,:121rejects unknown providers). As written, every provider added server-side breaks every older client.electron-builder.jsonhand-enumeratessrc/stores/policyRules.tsandsrc/services/transcriptionBaseUrl.tsfile by file, which is the packaging config signalling how fragile this is. Bundling main would remove the whole bug class.