Skip to content

fix: require a non-empty OpenAI key on first run - #93

Open
utsxvrai wants to merge 1 commit into
BuilderIO:mainfrom
utsxvrai:fix/require-openai-key-on-first-run
Open

utsxvrai wants to merge 1 commit into
BuilderIO:mainfrom
utsxvrai:fix/require-openai-key-on-first-run

Conversation

@utsxvrai

Copy link
Copy Markdown

What

Pressing Enter at the "What is your OpenAI key?" first-run prompt without typing anything saved OPENAI_KEY=undefined to ~/.micro-agent. After that every run sent the literal string "undefined" as the key and failed with a 401, and since a key was now "set" the prompt never came back. This adds validation to that prompt so an empty or whitespace key isn't accepted, and trims the key before saving. It also fixes the key validator in micro-agent config, which threw on an empty submit because the value is undefined there.

Fixes #78

Tests

  • New interactive-mode.test.ts: the validator rejects empty input, the key is saved trimmed, and you aren't prompted when a key already exists.
  • Added a config UI test for the empty-key validator.
  • npm run lint and npm test pass (55 passed).

Submitting the first-run key prompt empty saved OPENAI_KEY=undefined to
~/.micro-agent, so every later run sent "undefined" as the API key and
failed with a 401 without ever asking for the key again.

Validate the key in the first-run prompt and in the config UI (which
crashed on an empty submit because the value is undefined), and trim it
before saving.

Fixes BuilderIO#78
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

When I enter with out adding an api key.

1 participant