Context
LilySdk.create in src/sdk.ts resolves baseUrl as options?.baseUrl ?? process.env.LILY_API_URL ?? process.env.LILY_BASE_URL ?? DEFAULT_API_URL, so the result is always a non-empty string. The very next statement, if (!baseUrl) throw new Error('baseUrl is required. ... LILY_API_URL environment variable.'), is dead code that can never execute, and the method's JSDoc ("Throws if no baseUrl is provided and no env var is set.") contradicts the code, which silently falls back to the public DEFAULT_API_URL. Only the constructor path genuinely throws for a missing baseUrl (resolveBaseUrl in src/config/resolve-config.ts raises LilyConfigError: baseUrl is required.), so the two documented construction routes advertise different error contracts.
Proposed Change
Remove the unreachable guard (or convert it into an assertion that the fallback is defined) and rewrite the LilySdk.create JSDoc to describe the actual precedence — explicit options.baseUrl > LILY_API_URL > LILY_BASE_URL > DEFAULT_API_URL — and to note that only the constructor throws for a missing baseUrl. Update tests/sdk-create-factory.test.ts/related sdk-create tests to pin the precedence chain and confirm create() never throws solely for a missing baseUrl.
Acceptance Criteria
LilySdk.create() with no options and no env vars constructs an SDK pointed at DEFAULT_API_URL, with no throw.
- The
if (!baseUrl) branch is removed or proven reachable by a test.
- The JSDoc documents the exact fallback order and no longer claims a missing-baseUrl error.
- Tests cover options-over-env precedence and confirm the constructor (not
create()) is the path that raises LilyConfigError.
Suggested Label (documentation)
ETA: 24 hours
Context
LilySdk.createinsrc/sdk.tsresolvesbaseUrlasoptions?.baseUrl ?? process.env.LILY_API_URL ?? process.env.LILY_BASE_URL ?? DEFAULT_API_URL, so the result is always a non-empty string. The very next statement,if (!baseUrl) throw new Error('baseUrl is required. ... LILY_API_URL environment variable.'), is dead code that can never execute, and the method's JSDoc ("Throws if no baseUrl is provided and no env var is set.") contradicts the code, which silently falls back to the publicDEFAULT_API_URL. Only the constructor path genuinely throws for a missing baseUrl (resolveBaseUrlinsrc/config/resolve-config.tsraisesLilyConfigError:baseUrlis required.), so the two documented construction routes advertise different error contracts.Proposed Change
Remove the unreachable guard (or convert it into an assertion that the fallback is defined) and rewrite the
LilySdk.createJSDoc to describe the actual precedence — explicitoptions.baseUrl>LILY_API_URL>LILY_BASE_URL>DEFAULT_API_URL— and to note that only the constructor throws for a missing baseUrl. Updatetests/sdk-create-factory.test.ts/related sdk-create tests to pin the precedence chain and confirmcreate()never throws solely for a missing baseUrl.Acceptance Criteria
LilySdk.create()with no options and no env vars constructs an SDK pointed atDEFAULT_API_URL, with no throw.if (!baseUrl)branch is removed or proven reachable by a test.create()) is the path that raisesLilyConfigError.Suggested Label (documentation)
ETA: 24 hours