Skip to content

Add parameter validation and fix model switch test #114

@bashandbone

Description

@bashandbone

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:

  • Minimum: 1
  • Maximum: 100

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:

  1. Change provider while keeping model name
  2. Expect warning about incompatibility
  3. 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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions