Repository navigation
fix(cli): read the key from provider.apiKeyEnv in sedum explore - #154
Conversation
explore read TYPESAFE_API_KEY directly, so a project that keeps its key in a custom variable failed with "Set TYPESAFE_API_KEY" while run and doctor worked. exploreProvider now loads the project config and reads the key from provider.apiKeyEnv when the provider is TypeSafe. It always passes the key to the adapter, even when empty, so the adapter cannot fall back to TYPESAFE_API_KEY. The missing-key message names the configured variable. Amp-Thread-ID: https://ampcode.com/threads/T-09962b75-0e4a-44c9-b9e2-bea9aff8ac44 Co-authored-by: Ignacio Gutierrez <nachojgutierrez@gmail.com>
|
3 findings · reviewed 🟠
|
CodeScene flagged explore at cyclomatic complexity 9. Loading the project credentials and wording the missing-key message are now their own helpers. Amp-Thread-ID: https://ampcode.com/threads/T-09962b75-0e4a-44c9-b9e2-bea9aff8ac44 Co-authored-by: Ignacio Gutierrez <nachojgutierrez@gmail.com>
PR-lens pointed out that the docs said explore ignores named environments, but loadProjectConfig applies the config's default `environment:`. That matches sedum run without --env, so keep the behavior, document it, and pin it with a test. Amp-Thread-ID: https://ampcode.com/threads/T-09962b75-0e4a-44c9-b9e2-bea9aff8ac44 Co-authored-by: Ignacio Gutierrez <nachojgutierrez@gmail.com>
Fixes item 1 from the alpha.17 UAT.
sedum explorereadTYPESAFE_API_KEYdirectly and ignoredprovider.apiKeyEnv. A project that keeps its key in a custom variable got "Set TYPESAFE_API_KEY to use the TypeSafe provider" and exit 3, whilerunanddoctorin the same project worked.exploreProviderloads the project config. When the provider is TypeSafe, it reads the key fromprovider.apiKeyEnv, falling back toTYPESAFE_API_KEYwhen that isn't set. The shell wins over.env, as before. Named environments don't apply because explore has no--env.TypeSafeAdapter, even when empty. Otherwise the adapter falls back toprocess.env.TYPESAFE_API_KEY, which a configured name is meant to replace.sedum.config.yamlnow stopsexplorewith its diagnostic (exit 3), as it doesrun. Before, explore didn't read the config at all.Checked
vitest run packages/cli: 340 passed; build, typecheck and lint pass.provider.apiKeyEnvand doesn't fall back toTYPESAFE_API_KEYwhen the custom variable is empty.provider.apiKeyEnv: TYPESAFE_LOCAL_E2E_API_KEYand the key only in.env:Set TYPESAFE_API_KEY…, exit 3.TYPESAFE_API_KEYset in the shell:Set TYPESAFE_LOCAL_E2E_API_KEY…, exit 3.apiKeyEnv:TYPESAFE_API_KEYfrom.envworks, exit 0.apiKeyEnv: 9-BAD: config diagnostic, exit 3.--mode randomwith an unset custom key: runs, exit 0.Merge after alpha.17 is published. A new commit on
mainreplaces the alpha.17 candidate under UAT. Until #153 is merged, the replacement candidate would also ship this pending changeset under the alpha.17 changelog.https://ampcode.com/threads/T-09962b75-0e4a-44c9-b9e2-bea9aff8ac44