Repository navigation
fix(update-manager): fix npm registry fallback schema and env-less npm path discovery - #1343
Conversation
…m path discovery Fixes two real npm update failures reproduced during end-to-end isolated update testing: 1. Allow CodexhostLatestRelease.releaseNotesUrl to be null and return null (instead of "") from fetchLatestNpmRelease(). Previously, when GitHub Release discovery failed or hit rate limits and fell back to the npm registry, releaseNotesUrl: "" failed updateCheckResultSchema validation (which requires a valid GitHub Release URL or null), breaking npm update checks and updates. 2. Add resolveNpmRuntimePaths() in @codexhost/update-manager and reuse it in both resolveInstalledUpdateContext() and console-server updates. When CODEXHOST_NPM_* environment variables are unset (for example when Desktop Shell launches the platform bin/codexhost directly without bin/codexhost.js), derive packageRoot, @codexhost/cli/bin/codexhost.js, node, and npm-cli.js from standard global npm layouts (flat or nested), while continuing to strictly reject explicitly set invalid CODEXHOST_NPM_* values.
|
To use Codex here, create a Codex account and connect to github. |
|
No actionable comments were generated in the recent review. Summary
Merge Risk:
|
Summary
Fix two npm update failures reproduced in end-to-end isolated update testing:
updateCheckResultSchemavalidation:fetchLatestNpmRelease(), returningreleaseNotesUrl: ""violatedgithubReleaseNotesUrlSchema.nullable()inupdateCheckResultSchema, causing Web RPC andcodexhost updateto fail with a Zodinvalid_formaterror.bin/codexhostfailed update checks:CODEXHOST_NPM_*environment variables were absent (such as when Desktop Shell invokesbin/codexhostdirectly instead of thebin/codexhost.jswrapper), update checks failed withCODEXHOST_NPM_NODE_PATH must be an absolute pathand reported version0.0.0.Changes
packages/update-manager/src/github-release.ts&packages/update-manager/src/npm-registry.ts: ChangeCodexhostLatestRelease.releaseNotesUrltostring | nulland returnreleaseNotesUrl: nullfromfetchLatestNpmRelease().packages/update-manager/src/distribution.ts&packages/update-manager/src/index.ts: ExportresolveNpmRuntimePaths()and use it inresolveInstalledUpdateContext(). Explicitly provided invalidCODEXHOST_NPM_*values (empty, relative, or mismatched package root) remain strictly rejected; only unset variables fall back to deriving paths from standard@codexhost/cli-*flat or nested global npm layouts (resolving regular non-symlinknpm-cli.jsfiles).packages/console-server/src/updates.ts: ReuseresolveNpmRuntimePaths()so standalone Console /codexhost updatealso works withoutCODEXHOST_NPM_*env vars.packages/update-manager/test/npm-registry.test.ts,packages/update-manager/test/distribution.test.ts,packages/host-runtime/test/update-coordinator.test.ts,packages/console-server/test/updates.test.ts: Add focused regression tests validating realfetchLatestNpmRelease()output throughupdateCheckResultSchema.parse(), testing flat/nested/custom-prefix env-less npm discovery, and verifying explicit invalidCODEXHOST_NPM_*env vars are still rejected.Visual Changes
No visual changes: backend update-manager, host-runtime, and console-server npm update discovery and runtime path resolution fixes only.
Validation
tsc -b packages/update-manager packages/console-server: passed (implementation session; verified allCodexhostLatestRelease/releaseNotesUrlconsumers across the workspace).packages/update-manager/test/,packages/host-runtime/test/update-coordinator.test.ts,packages/console-server/test/updates.test.ts): 11 test files, 123 passed, 1 platform-skipped (implementation session; verified npm fallback regression failed before the fix).pre-commitPrettier formatting check on all 9 changed files: passed.AGENTS.md.