-
Couldn't load subscription status.
- Fork 1
Fix OpenAI connector health check configuration #648
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
WalkthroughThe initialization logic in src/connectors/openai.py now determines whether to disable health checks by reading an AppConfig attribute (disable_health_checks) via getattr, replacing the previous nested config key lookup ("session.dangerous_command_prevention_enabled"). Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant App as Application
participant Cfg as AppConfig
participant Conn as OpenAIConnector
User->>App: start()
App->>Cfg: load configuration
App->>Conn: initialize(conn_config=Cfg)
note over Conn: Determine health-check behavior
Conn->>Cfg: getattr(Cfg, "disable_health_checks", False)
alt disable_health_checks == True
note right of Conn: Health checks disabled
Conn-->>App: init complete (no health checks)
else
note right of Conn: Health checks enabled
Conn-->>App: init complete (health checks on)
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/connectors/openai.py(1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.py
📄 CodeRabbit inference engine (AGENTS.md)
**/*.py: Avoid using emojis in Python code comments or docstrings
Follow PEP 8 and use type hints for all functions
Import order must be: standard library, third-party, then local imports, separated by blank lines
Naming conventions: snake_case for variables and functions; PascalCase for classes
Error handling: use specific exceptions and include meaningful error messages
Prefer f-strings for string formatting
Files:
src/connectors/openai.py
src/**/*.py
📄 CodeRabbit inference engine (AGENTS.md)
src/**/*.py: Catch specific exceptions; avoid broad except Exception blocks
If a broad exception must be caught, log with exc_info=True and re-raise a specific custom exception
Use the most specific exception class from src.core.common.exceptions that accurately describes the error
Provide clear, helpful error messages and include relevant details in the details dictionary of custom exceptions
Files:
src/connectors/openai.py
🧬 Code graph analysis (1)
src/connectors/openai.py (2)
tests/unit/core/services/test_json_repair_middleware_gate.py (1)
config(17-30)tests/unit/core/services/test_json_repair_middleware.py (1)
config(18-24)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: test (3.10)
- GitHub Check: Analyze (python)
| disable_health_checks_config = bool( | ||
| getattr(self.config, "disable_health_checks", False) | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
Good change to use a dedicated health check flag, but verify the attribute exists on AppConfig.
The shift from session.dangerous_command_prevention_enabled to a top-level disable_health_checks attribute is architecturally sound and aligns with the PR objective of using a dedicated configuration flag for health checks.
However, please verify that:
- The
disable_health_checksattribute is actually defined on theAppConfigclass - No other code still references
session.dangerous_command_prevention_enabledfor health check purposes - Tests are updated to use the new configuration attribute
Run the following verification scripts:
🏁 Script executed:
#!/bin/bash
# Description: Verify that disable_health_checks attribute exists on AppConfig class
# Find the AppConfig class definition and check for disable_health_checks attribute
echo "=== Searching for AppConfig class definition and disable_health_checks attribute ==="
ast-grep --pattern $'class AppConfig$$$:
$$$
disable_health_checks$$$
$$$'
# Alternative: search for the attribute definition in config files
echo -e "\n=== Searching for disable_health_checks in config-related files ==="
rg -n --type=py -C5 'disable_health_checks' -g 'src/core/config/**'Length of output: 1936
🏁 Script executed:
#!/bin/bash
# Description: Check for any remaining references to the old config key
# Search for any code still using session.dangerous_command_prevention_enabled
echo "=== Searching for old config key references ==="
rg -n --type=py 'dangerous_command_prevention_enabled' -C3
# Check if this key is still being set or read elsewhere
echo -e "\n=== Checking for session config with dangerous_command_prevention ==="
rg -n --type=py 'SessionConfig.*dangerous' -C3Length of output: 3619
Update remaining references to session.dangerous_command_prevention_enabled
- Remove
dangerous_command_prevention_enabledfield and its env-var mapping insrc/core/config/app_config.py. - In
src/core/persistence.py::_should_raise_strict_errors, replaceconfig.get("session.dangerous_command_prevention_enabled")withconfig.disable_health_checks. - In
src/core/di/services.py(around line 1052), usenot app_config.disable_health_checksinstead ofapp_config.session.dangerous_command_prevention_enabled. - In
tests/utils/app_builder.py, setAppConfig.disable_health_checksrather than the old session flag.
🤖 Prompt for AI Agents
In src/connectors/openai.py around lines 74-76, replace the getattr(self.config,
"disable_health_checks", False) pattern with direct use of the new boolean
attribute config.disable_health_checks (rename local variable to something like
disable_health_checks) and use that value where needed; additionally, remove any
remaining references to session.dangerous_command_prevention_enabled across the
codebase: delete the field and its env-var mapping in
src/core/config/app_config.py, update
src/core/persistence.py::_should_raise_strict_errors to use
config.disable_health_checks instead of
config.get("session.dangerous_command_prevention_enabled"), change the check in
src/core/di/services.py (around line 1052) to use not
app_config.disable_health_checks in place of
app_config.session.dangerous_command_prevention_enabled, and update
tests/utils/app_builder.py to set AppConfig.disable_health_checks rather than
the old session flag.
Summary
Testing
https://chatgpt.com/codex/tasks/task_e_68ec26beb3b0833397f9204b4e11ff80
Summary by CodeRabbit