Fix: Connection test to not just check 200#688
Conversation
📝 WalkthroughWalkthroughHTTP status handling in the connection validator was changed: Changes
Sequence DiagramsequenceDiagram
participant Client as HTTP Endpoint
participant Validator as Connection Validator
participant Config as URLTestConfig
Client->>Validator: Respond with HTTP status
Validator->>Config: Read expected_status_code
alt expected_status_code is set
Config-->>Validator: configured value
Validator->>Validator: Compare observed == expected
alt equal
Validator->>Validator: Log success (include status), return NodeCondition
else not equal
Validator->>Validator: Log error, return None
end
else expected_status_code is None
Config-->>Validator: None (flexible mode)
Validator->>Config: Check retriable_status_codes
alt status in retriable_status_codes
Validator->>Validator: Log warning, return None (retry)
else not retriable
Validator->>Validator: Check if status is 5xx
alt is 5xx
Validator->>Validator: Log error, return None
else
Validator->>Validator: Log info, return NodeCondition (include status)
end
end
end
Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
b13aabb to
aef0005
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/operator/utils/node_validation_test/connection_validator.py (1)
165-172: Consider clarifying the fallback behavior for 5xx codes.The condition
status_code in url_config.failure_status_codes or status_code >= 500means all 5xx codes are treated as failures regardless of thefailure_status_codesconfiguration. The explicit list provides documentation value but can't be used to exclude specific 5xx codes from being failures.If this is intentional (5xx should always fail), consider simplifying or adding a comment to clarify:
# All 5xx codes are failures; explicit list is for clarity/documentation if status_code >= 500:If users should be able to configure which 5xx codes are failures, remove the
or status_code >= 500fallback.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/operator/utils/node_validation_test/connection_validator.py` around lines 165 - 172, The current check in the connection validator treats every 5xx as failure by combining status_code in url_config.failure_status_codes or status_code >= 500; decide and implement one of two fixes: (A) if 5xx should always fail, simplify the condition to just if status_code >= 500 and add a clarifying comment above it, or (B) if callers should be able to control which 5xx codes fail, remove the "or status_code >= 500" clause so only values in url_config.failure_status_codes trigger the failure branch; update the logging message in the failure branch (the block using status_code and url_config.url) if you change the condition to reflect the chosen behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/operator/utils/node_validation_test/connection_validator.py`:
- Around line 165-172: The current check in the connection validator treats
every 5xx as failure by combining status_code in url_config.failure_status_codes
or status_code >= 500; decide and implement one of two fixes: (A) if 5xx should
always fail, simplify the condition to just if status_code >= 500 and add a
clarifying comment above it, or (B) if callers should be able to control which
5xx codes fail, remove the "or status_code >= 500" clause so only values in
url_config.failure_status_codes trigger the failure branch; update the logging
message in the failure branch (the block using status_code and url_config.url)
if you change the condition to reflect the chosen behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: c8137bdc-f014-4189-845c-c619b5502587
📒 Files selected for processing (1)
src/operator/utils/node_validation_test/connection_validator.py
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/operator/utils/node_validation_test/connection_validator.py (1)
124-131: Docstring references hardcoded status codes that are actually configurable.The docstring says "Retriable codes (429, 503)" but these values come from
url_config.retriable_status_codesand can be customized per URL config. Consider updating the docstring to reflect this:📝 Suggested docstring update
Status code handling: - If expected_status_code is set, only that code is considered success - If expected_status_code is None (default): - - Retriable codes (429, 503) trigger retry + - Codes in retriable_status_codes (default: 429, 503) trigger retry - Any other 5xx indicates service is down - All other codes (2xx, 3xx, 4xx) indicate service is reachable🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/operator/utils/node_validation_test/connection_validator.py` around lines 124 - 131, Update the docstring to stop hardcoding "Retriable codes (429, 503)" and instead state that retriable codes come from the URL configuration (url_config.retriable_status_codes) and may be customized per URL; keep the rest of the logic description (expected_status_code behavior, 5xx handling, reachable codes) but reference url_config.retriable_status_codes where retriable codes are mentioned and note the default set is used when not overridden.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/operator/utils/node_validation_test/connection_validator.py`:
- Around line 124-131: Update the docstring to stop hardcoding "Retriable codes
(429, 503)" and instead state that retriable codes come from the URL
configuration (url_config.retriable_status_codes) and may be customized per URL;
keep the rest of the logic description (expected_status_code behavior, 5xx
handling, reachable codes) but reference url_config.retriable_status_codes where
retriable codes are mentioned and note the default set is used when not
overridden.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 376c3327-4518-4e8a-a747-0a8421e2341e
📒 Files selected for processing (1)
src/operator/utils/node_validation_test/connection_validator.py
Description
Connection check should not just check 200 but should retry on 429 and handle other status codes
Issue - None
Checklist
Summary by CodeRabbit