Skip to content

Commit 383e7d3

Browse files
hieu-leeclaude
andcommitted
fix(contracts): keep whitespace in t3-launcher install paths
TrimmedNonEmptyString trimmed launcher and baseDir on decode and encode, so a path with leading or trailing whitespace would point the copied update command at a different home. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
1 parent 3f2a4ec commit 383e7d3

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

‎packages/contracts/src/environment.test.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ describe("ExecutionEnvironmentDescriptor", () => {
2828
}).capabilities.serverInstallation,
2929
).toEqual(installation);
3030
}
31+
const spaced = { kind: "t3-launcher", launcher: "/opt/bin/t3 ", baseDir: " /data/t3 " };
32+
expect(
33+
decodeDescriptor({
34+
...descriptor,
35+
capabilities: { ...descriptor.capabilities, serverInstallation: spaced },
36+
}).capabilities.serverInstallation,
37+
).toEqual(spaced);
3138
for (const installation of [
3239
{ kind: "future-manager" },
3340
{ kind: "npm-global" },

‎packages/contracts/src/environment.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,17 @@ export type ExecutionEnvironmentPlatform = typeof ExecutionEnvironmentPlatform.T
6161
export const ServerSelfUpdateMethod = Schema.Literals(["boot-service", "respawn", "desktop-app"]);
6262
export type ServerSelfUpdateMethod = typeof ServerSelfUpdateMethod.Type;
6363

64+
// Not trimmed: a path that differs from the installed one would update the wrong home.
65+
const InstalledPath = Schema.String.check(Schema.isNonEmpty());
66+
6467
export const ServerInstallation = Schema.Union([
6568
Schema.Struct({ kind: Schema.Literals(["npx", "pnpm-dlx", "bunx"]) }),
6669
Schema.Struct({ kind: Schema.Literal("npm-global"), prefix: TrimmedNonEmptyString }),
6770
// A launcher symlink into a downloaded runtime, as the install script and `t3 update` leave.
6871
Schema.Struct({
6972
kind: Schema.Literal("t3-launcher"),
70-
launcher: TrimmedNonEmptyString,
71-
baseDir: TrimmedNonEmptyString,
73+
launcher: InstalledPath,
74+
baseDir: InstalledPath,
7275
}),
7376
]);
7477
export type ServerInstallation = typeof ServerInstallation.Type;

0 commit comments

Comments
 (0)