Description
Add validation to find_code API to enforce reasonable parameter bounds and improve test coverage.
Test File TODOs
1. Validate max_results Bounds (test_find_code_contract.py:380)
Add validation in find_code to enforce:
- Minimum: 1
- Maximum: 100000
Current State:
- No validation on max_results
- Tests note this should be enforced
2. Validate max_chunks_per_file Bounds (test_find_code_contract.py:389)
Add validation in find_code to enforce:
Current State:
- No validation on max_chunks_per_file
- Tests note this should be enforced
3. Fix Model Switch Test (test_model_switch.py:86)
Test isn't testing the correct behavior for model switching warnings.
Current Problem:
Comment states: "This isn't testing the correct thing. The warning should raise if the embedding provider changes but the model doesn't"
Expected Behavior:
- Warning when provider changes but model stays the same
- This indicates potential embedding incompatibility
- Current test doesn't capture this scenario
Implementation
API Validation
Add to find_code():
if max_results < 1 or max_results > 100000:
raise ValueError("max_results must be between 1 and 100000")
if max_chunks_per_file < 1 or max_chunks_per_file > 100:
raise ValueError("max_chunks_per_file must be between 1 and 100")
Test Fix
Rewrite model switch test to:
- Change provider while keeping model name
- Expect warning about incompatibility
- Verify warning message content
Benefits
- Safety: Prevent unreasonable parameter values
- Correctness: Tests validate actual requirements
- User experience: Clear error messages
Source
- Files:
test_find_code_contract.py:380,389, test_model_switch.py:86
- Branch:
003-our-aim-to
Description
Add validation to find_code API to enforce reasonable parameter bounds and improve test coverage.
Test File TODOs
1. Validate max_results Bounds (test_find_code_contract.py:380)
Add validation in find_code to enforce:
Current State:
2. Validate max_chunks_per_file Bounds (test_find_code_contract.py:389)
Add validation in find_code to enforce:
Current State:
3. Fix Model Switch Test (test_model_switch.py:86)
Test isn't testing the correct behavior for model switching warnings.
Current Problem:
Comment states: "This isn't testing the correct thing. The warning should raise if the embedding provider changes but the model doesn't"
Expected Behavior:
Implementation
API Validation
Add to
find_code():Test Fix
Rewrite model switch test to:
Benefits
Source
test_find_code_contract.py:380,389,test_model_switch.py:86003-our-aim-to