Skip to content

Commit 0fe51dd

Browse files
committed
fix: trim whitespace in asNonEmptyString and remove unnecessary export from adjustModelsForSubscription
- asNonEmptyString now trims the string before checking length, preventing whitespace-only strings from passing through and later failing TrimmedNonEmptyString schema validation on the client. - adjustModelsForSubscription is only used within ClaudeProvider.ts, so remove the export to keep the module's public API surface minimal.
1 parent 82afe2a commit 0fe51dd

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

apps/server/src/provider/Layers/ClaudeProvider.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,11 @@ const SUBSCRIPTION_TYPE_KEYS = [
218218
const SUBSCRIPTION_CONTAINER_KEYS = ["account", "subscription", "user", "billing"] as const;
219219

220220
/** Lift an unknown value into `Option<string>` if it is a non-empty string. */
221-
const asNonEmptyString = (v: unknown): Option.Option<string> =>
222-
typeof v === "string" && v.length > 0 ? Option.some(v) : Option.none();
221+
const asNonEmptyString = (v: unknown): Option.Option<string> => {
222+
if (typeof v !== "string") return Option.none();
223+
const trimmed = v.trim();
224+
return trimmed.length > 0 ? Option.some(trimmed) : Option.none();
225+
};
223226

224227
/** Lift an unknown value into `Option<Record>` if it is a plain object. */
225228
const asRecord = (v: unknown): Option.Option<Record<string, unknown>> =>
@@ -283,7 +286,7 @@ const PREMIUM_SUBSCRIPTION_TYPES = new Set([
283286
* - Other tiers (Pro, free, unknown): 200k context stays the default;
284287
* 1M remains available as a manual option so users can still enable it.
285288
*/
286-
export function adjustModelsForSubscription(
289+
function adjustModelsForSubscription(
287290
baseModels: ReadonlyArray<ServerProviderModel>,
288291
subscriptionType: string | undefined,
289292
): ReadonlyArray<ServerProviderModel> {

0 commit comments

Comments
 (0)