fix: validate API key is not empty in HTTPRequest node#29950
fix: validate API key is not empty in HTTPRequest node#29950crazywoola merged 2 commits intolanggenius:mainfrom
Conversation
- Add validation after template conversion to check for empty/whitespace API keys - Raise AuthorizationConfigError with clear message when API key is empty - Prevents invalid headers like 'Basic ' from being created - Add comprehensive unit tests for all auth types (bearer, basic, custom) - Update integration tests to verify proper error handling Fixes langgenius#21830
Summary of ChangesHello @AziizBg, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request resolves an issue where the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request effectively resolves the issue of the HTTPRequest node failing with an empty API key by introducing validation early in the executor's initialization. The changes are well-implemented, and the inclusion of both unit and integration tests ensures the fix is robust and reliable. My feedback includes a couple of suggestions for improving code conciseness and test maintainability.
Fix: HTTPRequest Node fails when API key is empty
Description
Fixes issue #21830 where the HTTPRequest node fails to execute when the API key used for authorization is empty, resulting in invalid headers like
"Basic "(with no credentials) and causing "Illegal header value" errors.Changes
Core Fix
Executor.__init__to check if API key is empty or whitespace-only after template conversionAuthorizationConfigErrorwith a clear error message when API key is emptyFiles Modified
api/core/workflow/nodes/http_request/executor.pyapi/tests/unit_tests/core/workflow/nodes/http_request/test_http_request_executor.pytest_empty_api_key_raises_error_bearer- Tests bearer auth with empty keytest_empty_api_key_raises_error_basic- Tests basic auth with empty keytest_empty_api_key_raises_error_custom- Tests custom auth with empty keytest_whitespace_only_api_key_raises_error- Tests whitespace-only keytest_valid_api_key_works- Ensures valid keys still workapi/tests/integration_tests/workflow/nodes/test_http.pytest_custom_auth_with_empty_api_key_raises_errorto expectAuthorizationConfigErrortest_custom_authorization_with_empty_api_keyto verify proper error handling in node executionTesting
Unit Tests
All new unit tests pass:
Integration Tests
Manual Testing
To test manually:
Impact
Related Issues
Fixes #21830
Checklist