Fix Anthropic config: remove trailing comma in access_token assignment #47
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The previous configuration was assigning the wrong @access_token when initializing a client
This PR fixes a small syntax issue in the initializer example for Anthropic.configure.
Currently, the example in the README shows:
config.access_token = ENV.fetch("ANTHROPIC_API_KEY"),
The trailing comma causes Ruby to interpret the value as a single-element array instead of a string:
Current behavior
ENV.fetch("ANTHROPIC_API_KEY"), # => ["sk-ant-api..."]
This results in @access_token being set to an array (with nil and true as seen in debug output), which leads to an invalid x-api-key authentication error when calling the API.
Fix:
Removed the trailing comma so the value is correctly assigned as a string:
config.access_token = ENV.fetch("ANTHROPIC_API_KEY")
This change ensures the access_token is passed correctly to the client and avoids 401 authentication errors.
Why it matters:
The current example can cause confusion for new users and lead to avoidable API authentication failures. This small fix improves developer onboarding and prevents subtle bugs.