@@ -321,6 +321,41 @@ def test_build_context_with_options(cli_env, setup_test_note):
321321 assert found , "Context did not include the test note"
322322
323323
324+ def test_build_context_string_depth_parameter (cli_env , setup_test_note ):
325+ """Test build_context command handles string depth parameter correctly."""
326+ permalink = setup_test_note ["permalink" ]
327+
328+ # Test valid string depth parameter - Typer should convert it to int
329+ result = runner .invoke (
330+ tool_app ,
331+ [
332+ "build-context" ,
333+ f"memory://{ permalink } " ,
334+ "--depth" ,
335+ "2" , # This is always a string from CLI
336+ ],
337+ )
338+ assert result .exit_code == 0
339+
340+ # Result should be JSON containing our test note with correct depth
341+ context_result = json .loads (result .stdout )
342+ assert context_result ["metadata" ]["depth" ] == 2
343+
344+ # Test invalid string depth parameter - should fail with Typer validation error
345+ result = runner .invoke (
346+ tool_app ,
347+ [
348+ "build-context" ,
349+ f"memory://{ permalink } " ,
350+ "--depth" ,
351+ "invalid" ,
352+ ],
353+ )
354+ assert result .exit_code == 2 # Typer exits with code 2 for parameter validation errors
355+ # Typer should show a usage error for invalid integer
356+ assert "invalid" in result .stderr and "is not a valid" in result .stderr and "integer" in result .stderr
357+
358+
324359# The get-entity CLI command was removed when tools were refactored
325360# into separate files with improved error handling
326361
0 commit comments