Skip to content

fix(openai): treat blank env API key as unconfigured in speech provider - #108212

Merged
steipete merged 7 commits into
openclaw:mainfrom
lsr911:fix-openai-speech-blank-api-key
Jul 15, 2026
Merged

steipete merged 7 commits into
openclaw:mainfrom
lsr911:fix-openai-speech-blank-api-key

Conversation

@lsr911

@lsr911 lsr911 commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

A whitespace-only OPENAI_API_KEY made the OpenAI speech provider report configured, then sent an unusable bearer credential from regular or telephony synthesis.

Closes #108186.

Why This Change Was Made

  • Resolve explicit config first, then the environment, through one trimToUndefined helper.
  • Reuse that normalized result in isConfigured, regular synthesis, and telephony synthesis.
  • Make realtime-transcription readiness trim the environment key, matching its already-normalized runtime authorization path.
  • Prune the stale max-lines baseline entry left when current main deleted src/agents/modes/interactive/theme/theme.ts; this was found by the exact-SHA gate.
  • Reject blank credentials locally before any network request.
  • Prove padded valid keys are trimmed consistently on both request paths.

This includes the clean shared-resolver approach from duplicate #108187. @ooiuuii is preserved as a coauthor alongside this PR's original contributor @lsr911.

User Impact

  • Before: whitespace-only credentials looked configured and failed later as a provider request.
  • After: blank credentials fail locally as missing; valid padded credentials work with the normalized value.

Verification

Risk / Compatibility

Low. Existing explicit-config precedence remains unchanged. Only surrounding whitespace and blank values are normalized. No config, SDK, or persistence surface changes.

Changelog

Release-note context only; no contributor-owned root changelog edit.

process.env.OPENAI_API_KEY set to whitespace-only (e.g. '   ') causes
isConfigured to return true, but downstream synthesis fails with an
unusable bearer token. Add ?.trim() to treat whitespace-only env keys
as missing, matching the existing normalization in the image-generation
provider (image-generation-provider.ts:347).

Fixes openclaw#108186
@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Jul 15, 2026
@steipete

Copy link
Copy Markdown
Contributor

Land-ready maintainer pass complete on exact head fdc63f17e178eaa0beb8df77b7717da026059899.

The original three raw speech-key reads are now one normalized resolver shared by readiness, regular synthesis, and telephony synthesis. The sibling realtime-transcription readiness check now matches its already-trimmed runtime authorization path. The exact-SHA gate also exposed a stale max-lines entry left when current main deleted theme.ts; this branch prunes it and the ratchet passes.

Proof:

Issue #108186 is linked with Closes. Duplicate #108187's shared-resolver work is included and @ooiuuii remains credited in the commit history alongside @lsr911.

@steipete
steipete merged commit 4108bbc into openclaw:main Jul 15, 2026
231 of 236 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 16, 2026
…er (openclaw#108212)

* fix(openai): treat blank env API key as unconfigured in speech provider

process.env.OPENAI_API_KEY set to whitespace-only (e.g. '   ') causes
isConfigured to return true, but downstream synthesis fails with an
unusable bearer token. Add ?.trim() to treat whitespace-only env keys
as missing, matching the existing normalization in the image-generation
provider (image-generation-provider.ts:347).

Fixes openclaw#108186

* test(openai): cover speech env key normalization

Co-authored-by: luyifan <[email protected]>

* fix(openai): normalize realtime transcription env key

* chore(ci): prune stale max-lines baseline

---------

Co-authored-by: Peter Steinberger <[email protected]>
Co-authored-by: luyifan <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
steipete pushed a commit to lsr911/openclaw that referenced this pull request Jul 16, 2026
A whitespace-only XIAOMI_API_KEY made the Xiaomi MiMo speech provider
report configured, then sent an unusable bearer credential from synthesis.

- Wrap process.env.XIAOMI_API_KEY with trimToUndefined in isConfigured
  so blank values are treated as not configured
- Wrap process.env.XIAOMI_API_KEY with trimToUndefined in synthesize
  so blank values are rejected locally before any network request
- Add test coverage for whitespace-only and blank env key in both paths

This matches the blank-credential guard applied in the OpenAI speech
provider (PR openclaw#108212).
steipete added a commit that referenced this pull request Jul 16, 2026
…er (#108558)

* fix(xiaomi): treat blank env API key as unconfigured in speech provider

A whitespace-only XIAOMI_API_KEY made the Xiaomi MiMo speech provider
report configured, then sent an unusable bearer credential from synthesis.

- Wrap process.env.XIAOMI_API_KEY with trimToUndefined in isConfigured
  so blank values are treated as not configured
- Wrap process.env.XIAOMI_API_KEY with trimToUndefined in synthesize
  so blank values are rejected locally before any network request
- Add test coverage for whitespace-only and blank env key in both paths

This matches the blank-credential guard applied in the OpenAI speech
provider (PR #108212).

* refactor(xiaomi): centralize speech key resolution

---------

Co-authored-by: Peter Steinberger <[email protected]>
steipete pushed a commit to lsr911/openclaw that referenced this pull request Jul 16, 2026
A whitespace-only INWORLD_API_KEY made the Inworld speech provider
report configured, then sent an unusable bearer credential from
synthesis, telephony synthesis, and voice listing.

- Wrap process.env.INWORLD_API_KEY with trimToUndefined in isConfigured
  so blank values are treated as not configured
- Wrap process.env.INWORLD_API_KEY with trimToUndefined in synthesize,
  synthesizeTelephony, and listVoices so blank values are rejected
  locally before any network request
- Add test coverage for whitespace-only env key in isConfigured and
  synthesize paths

This matches the blank-credential guard pattern applied in the OpenAI
(openclaw#108212), Xiaomi (openclaw#108558), and Deepgram (openclaw#108565) providers.

Co-Authored-By: Claude <[email protected]>
steipete added a commit that referenced this pull request Jul 16, 2026
…der (#108783)

* fix(inworld): treat blank env API key as unconfigured in speech provider

A whitespace-only INWORLD_API_KEY made the Inworld speech provider
report configured, then sent an unusable bearer credential from
synthesis, telephony synthesis, and voice listing.

- Wrap process.env.INWORLD_API_KEY with trimToUndefined in isConfigured
  so blank values are treated as not configured
- Wrap process.env.INWORLD_API_KEY with trimToUndefined in synthesize,
  synthesizeTelephony, and listVoices so blank values are rejected
  locally before any network request
- Add test coverage for whitespace-only env key in isConfigured and
  synthesize paths

This matches the blank-credential guard pattern applied in the OpenAI
(#108212), Xiaomi (#108558), and Deepgram (#108565) providers.

Co-Authored-By: Claude <[email protected]>

* fix(inworld): centralize speech API key resolution

---------

Co-authored-by: Claude <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
steipete pushed a commit to lsr911/openclaw that referenced this pull request Jul 16, 2026
The isGradiumProviderConfigured helper already uses trimToUndefined on
GRADIUM_API_KEY, but synthesize and synthesizeTelephony still used the
bare env var. This made whitespace-only credentials pass the
missing-key guard and send unusable bearer tokens.

- Wrap process.env.GRADIUM_API_KEY with trimToUndefined in synthesize
- Wrap process.env.GRADIUM_API_KEY with trimToUndefined in
  synthesizeTelephony
- Add test for whitespace-only env key rejection in synthesize

This completes the blank-credential guard for the Gradium provider,
matching the pattern from OpenAI (openclaw#108212), Xiaomi (openclaw#108558),
Deepgram (openclaw#108565), and Inworld (openclaw#108783).

Co-Authored-By: Claude <[email protected]>
steipete added a commit that referenced this pull request Jul 16, 2026
…ths (#108800)

* fix(gradium): treat blank env API key as unconfigured in synthesis paths

The isGradiumProviderConfigured helper already uses trimToUndefined on
GRADIUM_API_KEY, but synthesize and synthesizeTelephony still used the
bare env var. This made whitespace-only credentials pass the
missing-key guard and send unusable bearer tokens.

- Wrap process.env.GRADIUM_API_KEY with trimToUndefined in synthesize
- Wrap process.env.GRADIUM_API_KEY with trimToUndefined in
  synthesizeTelephony
- Add test for whitespace-only env key rejection in synthesize

This completes the blank-credential guard for the Gradium provider,
matching the pattern from OpenAI (#108212), Xiaomi (#108558),
Deepgram (#108565), and Inworld (#108783).

Co-Authored-By: Claude <[email protected]>

* fix(gradium): centralize speech API key resolution

---------

Co-authored-by: Claude <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 17, 2026
…er (openclaw#108558)

* fix(xiaomi): treat blank env API key as unconfigured in speech provider

A whitespace-only XIAOMI_API_KEY made the Xiaomi MiMo speech provider
report configured, then sent an unusable bearer credential from synthesis.

- Wrap process.env.XIAOMI_API_KEY with trimToUndefined in isConfigured
  so blank values are treated as not configured
- Wrap process.env.XIAOMI_API_KEY with trimToUndefined in synthesize
  so blank values are rejected locally before any network request
- Add test coverage for whitespace-only and blank env key in both paths

This matches the blank-credential guard applied in the OpenAI speech
provider (PR openclaw#108212).

* refactor(xiaomi): centralize speech key resolution

---------

Co-authored-by: Peter Steinberger <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 17, 2026
…der (openclaw#108783)

* fix(inworld): treat blank env API key as unconfigured in speech provider

A whitespace-only INWORLD_API_KEY made the Inworld speech provider
report configured, then sent an unusable bearer credential from
synthesis, telephony synthesis, and voice listing.

- Wrap process.env.INWORLD_API_KEY with trimToUndefined in isConfigured
  so blank values are treated as not configured
- Wrap process.env.INWORLD_API_KEY with trimToUndefined in synthesize,
  synthesizeTelephony, and listVoices so blank values are rejected
  locally before any network request
- Add test coverage for whitespace-only env key in isConfigured and
  synthesize paths

This matches the blank-credential guard pattern applied in the OpenAI
(openclaw#108212), Xiaomi (openclaw#108558), and Deepgram (openclaw#108565) providers.

Co-Authored-By: Claude <[email protected]>

* fix(inworld): centralize speech API key resolution

---------

Co-authored-by: Claude <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 17, 2026
…ths (openclaw#108800)

* fix(gradium): treat blank env API key as unconfigured in synthesis paths

The isGradiumProviderConfigured helper already uses trimToUndefined on
GRADIUM_API_KEY, but synthesize and synthesizeTelephony still used the
bare env var. This made whitespace-only credentials pass the
missing-key guard and send unusable bearer tokens.

- Wrap process.env.GRADIUM_API_KEY with trimToUndefined in synthesize
- Wrap process.env.GRADIUM_API_KEY with trimToUndefined in
  synthesizeTelephony
- Add test for whitespace-only env key rejection in synthesize

This completes the blank-credential guard for the Gradium provider,
matching the pattern from OpenAI (openclaw#108212), Xiaomi (openclaw#108558),
Deepgram (openclaw#108565), and Inworld (openclaw#108783).

Co-Authored-By: Claude <[email protected]>

* fix(gradium): centralize speech API key resolution

---------

Co-authored-by: Claude <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
zooqueen pushed a commit to zooqueen/openclaw that referenced this pull request Sep 11, 2026
…er (openclaw#108212)

* fix(openai): treat blank env API key as unconfigured in speech provider

process.env.OPENAI_API_KEY set to whitespace-only (e.g. '   ') causes
isConfigured to return true, but downstream synthesis fails with an
unusable bearer token. Add ?.trim() to treat whitespace-only env keys
as missing, matching the existing normalization in the image-generation
provider (image-generation-provider.ts:347).

Fixes openclaw#108186

* test(openai): cover speech env key normalization

Co-authored-by: luyifan <[email protected]>

* fix(openai): normalize realtime transcription env key

* chore(ci): prune stale max-lines baseline

---------

Co-authored-by: Peter Steinberger <[email protected]>
Co-authored-by: luyifan <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
zooqueen pushed a commit to zooqueen/openclaw that referenced this pull request Sep 11, 2026
…er (openclaw#108558)

* fix(xiaomi): treat blank env API key as unconfigured in speech provider

A whitespace-only XIAOMI_API_KEY made the Xiaomi MiMo speech provider
report configured, then sent an unusable bearer credential from synthesis.

- Wrap process.env.XIAOMI_API_KEY with trimToUndefined in isConfigured
  so blank values are treated as not configured
- Wrap process.env.XIAOMI_API_KEY with trimToUndefined in synthesize
  so blank values are rejected locally before any network request
- Add test coverage for whitespace-only and blank env key in both paths

This matches the blank-credential guard applied in the OpenAI speech
provider (PR openclaw#108212).

* refactor(xiaomi): centralize speech key resolution

---------

Co-authored-by: Peter Steinberger <[email protected]>
zooqueen pushed a commit to zooqueen/openclaw that referenced this pull request Sep 11, 2026
…der (openclaw#108783)

* fix(inworld): treat blank env API key as unconfigured in speech provider

A whitespace-only INWORLD_API_KEY made the Inworld speech provider
report configured, then sent an unusable bearer credential from
synthesis, telephony synthesis, and voice listing.

- Wrap process.env.INWORLD_API_KEY with trimToUndefined in isConfigured
  so blank values are treated as not configured
- Wrap process.env.INWORLD_API_KEY with trimToUndefined in synthesize,
  synthesizeTelephony, and listVoices so blank values are rejected
  locally before any network request
- Add test coverage for whitespace-only env key in isConfigured and
  synthesize paths

This matches the blank-credential guard pattern applied in the OpenAI
(openclaw#108212), Xiaomi (openclaw#108558), and Deepgram (openclaw#108565) providers.

Co-Authored-By: Claude <[email protected]>

* fix(inworld): centralize speech API key resolution

---------

Co-authored-by: Claude <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
zooqueen pushed a commit to zooqueen/openclaw that referenced this pull request Sep 11, 2026
…ths (openclaw#108800)

* fix(gradium): treat blank env API key as unconfigured in synthesis paths

The isGradiumProviderConfigured helper already uses trimToUndefined on
GRADIUM_API_KEY, but synthesize and synthesizeTelephony still used the
bare env var. This made whitespace-only credentials pass the
missing-key guard and send unusable bearer tokens.

- Wrap process.env.GRADIUM_API_KEY with trimToUndefined in synthesize
- Wrap process.env.GRADIUM_API_KEY with trimToUndefined in
  synthesizeTelephony
- Add test for whitespace-only env key rejection in synthesize

This completes the blank-credential guard for the Gradium provider,
matching the pattern from OpenAI (openclaw#108212), Xiaomi (openclaw#108558),
Deepgram (openclaw#108565), and Inworld (openclaw#108783).

Co-Authored-By: Claude <[email protected]>

* fix(gradium): centralize speech API key resolution

---------

Co-authored-by: Claude <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: openai size: S triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OpenAI speech treats blank env API key as configured

2 participants