Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): a saved source control token that can't be read no longer falls back to another account #31646

Mergedjuliusmarmingemerged 3 commits intomain fromrefs/pull/31646/headmerged by juliusmarminge View on GitHub

Showing 16 changed files with 40 additions and 14 deletions (loading 13).

x
0 of 16 viewed, 16 left
8 additions and 12 deletionsapps/server/src/secrets/settingsSecretValue.tsModified
View file
@@ -1,16 +1,18 @@
import {
isSecretReference,
secretReferencesInSettings,
+ SettingsSecretUnresolvedError,
type SettingsSecretValue,
withSettingsSecrets,
} from "@t3tools/contracts";
import type * as SecretResolver from "@t3tools/secret-provider-core/server/SecretResolver";
import * as Effect from "effect/Effect";
-import * as Schema from "effect/Schema";
+import type * as Schema from "effect/Schema";
​
/**
* Replaces each reference in the slots `schema` declares as `SettingsSecretValue` with the secret
- * it names, read in one batch. An unreadable secret comes back as `""`, so it behaves as unset.
+ * it names, read in one batch. A secret that cannot be read, or reads empty, keeps its reference,
+ * which `requireSettingsSecretLiteral` turns into an error for the consumer of that field.
*/
export const resolveSettingsSecrets = Effect.fn("SettingsSecrets.resolve")(function* <
Settings extends Readonly<Record<string, unknown>>,
@@ -20,19 +22,13 @@
const values = yield* resolver.read(pending.map(({ reference }) => reference));
return withSettingsSecrets(
settings,
- pending.map((slot, index) => ({ ...slot, value: values[index] ?? "" })),
+ pending.flatMap((slot, index) => {
+ const value = values[index];
+ return value === undefined || value.trim() === "" ? [] : [{ ...slot, value }];
+ }),