Skip to content

Fix empty provider api keys - #144

Open
rayan-sharma-git wants to merge 2 commits into
slack-samples:mainfrom
rayan-sharma-git:fix-empty-provider-api-keys
Open

rayan-sharma-git wants to merge 2 commits into
slack-samples:mainfrom
rayan-sharma-git:fix-empty-provider-api-keys

Conversation

@rayan-sharma-git

@rayan-sharma-git rayan-sharma-git commented Sep 19, 2026 •

Copy link
Copy Markdown

Type of change

  • New feature
  • Bug fix
  • Documentation

Summary

The OpenAI and Anthropic providers treated an empty API key as valid because they checked whether the value was not None.

Changed:

if self.api_key is not None:

to:

if self.api_key:

This ensures the providers are only considered available when an API key is actually provided.
is not None treats an empty string ('') as valid because '' is still a value and is not None, while if self.api_key checks whether the value actually contains something.

For example:

self.api_key = ''

Then:

if self.api_key is not None: # True
if self.api_key: # False

Fixes #57

Requirements

  • I have ensured the changes I am contributing align with existing patterns and have tested and linted my code
  • I've read and agree to the Code of Conduct

Changed the API key check from:

if self.api_key is not None:

to:

if self.api_key:

The previous check considered an empty API key as valid because an empty string is not None. The new check only considers the provider available when an actual API key is provided.
Changed the API key check from:

if self.api_key is not None:

to:

if self.api_key:

The previous check treated an empty API key as valid. The new check only considers the OpenAI provider available when an API key is actually provided.
@rayan-sharma-git
rayan-sharma-git requested a review from a team as a code owner September 19, 2026 13:51
@salesforce-cla

Copy link
Copy Markdown

Thanks for the contribution! Before we can merge this, we need @rayan-sharma-git to sign the Salesforce Inc. Contributor License Agreement.

@rayan-sharma-git

Copy link
Copy Markdown
Author

Hi, I have already signed the Salesforce CLA using my GitHub account, and I have also added and verified the email address used for the CLA in my GitHub account. However, the CLA check on this PR is still showing as missing. Could someone please re-check/re-run the CLA verification for this PR? Thank you.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: avoid attempts of using blank environment variables as api keys

1 participant