fix: include missing optionalKeys when building config from env - #51
fix: include missing optionalKeys when building config from env#51DrunkOldDog wants to merge 2 commits into
Conversation
Greptile SummaryThis PR fixes a configuration gap where optional
Confidence Score: 4/5Safe to merge; the fix is small, correct, and backed by a good regression test — the only note is that WORKOS_COOKIE_SAME_SITE values coming from the environment are not validated against the allowed union at runtime. The core change is a two-line addition that unblocks a real, reproducible bug. The regression test is well-constructed and directly targets the failure mode. The only gap is that convertValueType does not validate cookieSameSite env-var strings against the union type, so a misconfigured env var would propagate silently — a quality concern rather than a breaking defect. src/core/config/ConfigurationProvider.ts — specifically the convertValueType method, which could benefit from a runtime guard on the cookieSameSite branch now that this value is read from the environment. Important Files Changed
|
Summary
Closes the config gap reported in workos/authkit-tanstack-start#114. Setting
WORKOS_COOKIE_DOMAIN(and the related optional env vars) had no effect unless callers also passed the value throughconfigure().getConfig()built its key set from:cookieName,apiHttps,cookieMaxAge,apiHostname)requiredKeys(clientId,apiKey,redirectUri,cookiePassword)Optional keys with no defaults —
cookieDomain,cookieSameSite,apiPort— were never included, so theirWORKOS_*env vars were never probed. Callingconfigure({ cookieDomain })hid the bug by putting the key onthis.configviaupdateConfig.This is why
@workos-inc/authkit-nextjswas unaffected (it reads env vars through its own layer), while adapters that rely on@workos/authkit-session(TanStack Start and others) ignoredWORKOS_COOKIE_DOMAINand wrote session cookies without aDomainattribute.Changes
optionalKeys(apiPort,cookieSameSite,cookieDomain) and include them in thegetConfig()key setWORKOS_COOKIE_DOMAIN/WORKOS_COOKIE_SAME_SITEon the correspondingAuthKitConfigfieldsconfigure()for those keys), soupdateConfigcannot mask the failureTest plan
pnpm test src/core/config/ConfigurationProvider.spec.ts— optional env vars are read withoutconfigure()getConfig()when unsetWORKOS_COOKIE_DOMAINin a TanStack Start app, sign in, confirmSet-CookieincludesDomain=