Skip to content

fix: avoid showing providers with an empty environment variable - #144

Merged
zimeg merged 3 commits into
slack-samples:mainfrom
rayan-sharma-git:fix-empty-provider-api-keys
Oct 13, 2026
Merged

zimeg merged 3 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
Contributor

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
Contributor 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.

@zimeg zimeg closed this Oct 8, 2026
@zimeg zimeg reopened this Oct 8, 2026
@zimeg zimeg changed the title Fix empty provider api keys fix: avoid showing providers with an empty environment variable Oct 13, 2026
@zimeg zimeg added the bug Something isn't working label Oct 13, 2026

@zimeg zimeg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rayan-sharma-git Thanks so much for taking a look and fix for this! LGTM!

@zimeg
zimeg merged commit 182c74a into slack-samples:main Oct 13, 2026
3 checks passed
@rayan-sharma-git
rayan-sharma-git deleted the fix-empty-provider-api-keys branch October 16, 2026 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working cla:signed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants