@devries-cameron20 / t3code Mirror · read-only / commits / f3b43a148b
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 24, 22:45 UTC

[codex] Structure missing client cloud config errors (#3346)

Co-authored-by: codex <codex@users.noreply.github.com>

Julius Marminge committed Jun 20, 2026 at 11:03 UTC f3b43a148b9e39192be5d43415289ac06eca1443
4 files changed +51 -4
apps/mobile/src/features/cloud/publicConfig.test.ts
+12 -1
@@ -1,6 +1,11 @@
1 import { describe, expect, it, vi } from "vite-plus/test";
2
3 -import { hasTracingPublicConfig, resolveCloudPublicConfig } from "./publicConfig";
3 +import {
4 + CloudPublicConfigMissingError,
5 + hasTracingPublicConfig,
6 + resolveCloudPublicConfig,
7 + resolveRelayClerkTokenOptions,
8 +} from "./publicConfig";
9
10 vi.mock("expo-constants", () => ({
11 default: {
@@ -11,6 +16,12 @@ vi.mock("expo-constants", () => ({
16 }));
17
18 describe("resolveCloudPublicConfig", () => {
19 + it("reports the missing Clerk JWT template as structured configuration", () => {
20 + expect(() => resolveRelayClerkTokenOptions()).toThrowError(
21 + new CloudPublicConfigMissingError({ key: "T3CODE_CLERK_JWT_TEMPLATE" }),
22 + );
23 + });
24 +
25 it("returns no cloud configuration for an unconfigured build", () => {
26 expect(resolveCloudPublicConfig({})).toEqual({
27 clerk: {
apps/mobile/src/features/cloud/publicConfig.ts
+13 -1
@@ -1,6 +1,18 @@
1 import Constants from "expo-constants";
2 import { relayClerkTokenOptions } from "@t3tools/shared/relayAuth";
3 import { normalizeSecureRelayUrl } from "@t3tools/shared/relayUrl";
4 +import * as Schema from "effect/Schema";
5 +
6 +export class CloudPublicConfigMissingError extends Schema.TaggedErrorClass<CloudPublicConfigMissingError>()(
7 + "CloudPublicConfigMissingError",
8 + {
9 + key: Schema.Literal("T3CODE_CLERK_JWT_TEMPLATE"),
10 + },
11 +) {
12 + override get message(): string {
13 + return `${this.key} is not configured.`;
14 + }
15 +}
16
17 export interface CloudPublicConfig {
18 readonly clerk: {
@@ -87,7 +99,7 @@ export function hasTracingPublicConfig(
99 export function resolveRelayClerkTokenOptions() {
100 const { jwtTemplate } = resolveCloudPublicConfig().clerk;
101 if (!jwtTemplate) {
90 - throw new Error("T3CODE_CLERK_JWT_TEMPLATE is not configured.");
102 + throw new CloudPublicConfigMissingError({ key: "T3CODE_CLERK_JWT_TEMPLATE" });
103 }
104 return relayClerkTokenOptions(jwtTemplate);
105 }
apps/web/src/cloud/publicConfig.test.ts
+13 -1
@@ -1,6 +1,10 @@
1 import { afterEach, describe, expect, it, vi } from "vite-plus/test";
2
3 -import { hasCloudPublicConfig } from "./publicConfig.ts";
3 +import {
4 + CloudPublicConfigMissingError,
5 + hasCloudPublicConfig,
6 + resolveRelayClerkTokenOptions,
7 +} from "./publicConfig.ts";
8
9 afterEach(() => {
10 vi.unstubAllEnvs();
@@ -30,4 +34,12 @@ describe("hasCloudPublicConfig", () => {
34
35 expect(hasCloudPublicConfig()).toBe(false);
36 });
37 +
38 + it("reports the missing Clerk JWT template as structured configuration", () => {
39 + vi.stubEnv("VITE_CLERK_JWT_TEMPLATE", "");
40 +
41 + expect(() => resolveRelayClerkTokenOptions()).toThrowError(
42 + new CloudPublicConfigMissingError({ key: "T3CODE_CLERK_JWT_TEMPLATE" }),
43 + );
44 + });
45 });
apps/web/src/cloud/publicConfig.ts
+13 -1
@@ -1,5 +1,17 @@
1 import { relayClerkTokenOptions } from "@t3tools/shared/relayAuth";
2 import { normalizeSecureRelayUrl } from "@t3tools/shared/relayUrl";
3 +import * as Schema from "effect/Schema";
4 +
5 +export class CloudPublicConfigMissingError extends Schema.TaggedErrorClass<CloudPublicConfigMissingError>()(
6 + "CloudPublicConfigMissingError",
7 + {
8 + key: Schema.Literal("T3CODE_CLERK_JWT_TEMPLATE"),
9 + },
10 +) {
11 + override get message(): string {
12 + return `${this.key} is not configured.`;
13 + }
14 +}
15
16 export interface CloudPublicConfig {
17 readonly clerkPublishableKey: string | null;
@@ -65,7 +77,7 @@ export function hasCloudPublicConfig(): boolean {
77 export function resolveRelayClerkTokenOptions() {
78 const { clerkJwtTemplate } = resolveCloudPublicConfig();
79 if (!clerkJwtTemplate) {
68 - throw new Error("T3CODE_CLERK_JWT_TEMPLATE is not configured.");
80 + throw new CloudPublicConfigMissingError({ key: "T3CODE_CLERK_JWT_TEMPLATE" });
81 }
82 return relayClerkTokenOptions(clerkJwtTemplate);
83 }