Skip to content

fix(fs_search): handle empty string file type from LLM tool calls#2355

Merged
amitksingh1490 merged 3 commits intomainfrom
fs_search-gpt-5
Feb 6, 2026
Merged

fix(fs_search): handle empty string file type from LLM tool calls#2355
amitksingh1490 merged 3 commits intomainfrom
fs_search-gpt-5

Conversation

@amitksingh1490
Copy link
Copy Markdown
Contributor

Summary

Fix fs_search tool crashing with "unrecognized file type" when LLMs send an empty string "" for the nullable type parameter, by adding empty-string-to-null coercion in the schema coercion layer and a defensive guard in the fs_search tool itself.

Context

When LLMs call the fs_search tool, they sometimes send "type": "" (an empty string) instead of omitting the parameter or sending null for the nullable file_type field. This caused the ignore crate's TypesBuilder::select("") to fail with:

Failed to build type matcher for:

Caused by:
    0: unrecognized file type:

The root issue is that the schema coercion layer (coerce_to_schema) didn't recognize the OpenAPI 3.0 "nullable": true extension on schema objects, so it had no way to know that an empty string for a nullable field should be converted to null.

Changes

Schema Coercion (forge_json_repair)

  • Added is_nullable() helper that checks the "nullable": true OpenAPI 3.0 extension on schema objects
  • Added early coercion logic that converts empty strings ("") to Value::Null when the schema marks a field as nullable
  • This is a global fix that applies to all nullable parameters across all tools, preventing the same class of errors

fs_search Tool (forge_services)

  • Added defensive guard that treats empty file_type strings as None via .as_deref().filter(|s| !s.is_empty())
  • This ensures the tool is robust even without the schema coercion layer

Tests

  • 4 new tests in schema_coercion: nullable string, nullable integer, non-empty string preservation, required field preservation
  • 1 new test in fs_search: verifies empty file_type doesn't crash and behaves as unfiltered search

Testing

# Run schema coercion tests
cargo test --package forge_json_repair -- test_coerce_empty_string_to_null

# Run preservation tests (ensure no regressions)
cargo test --package forge_json_repair -- test_preserve

# Run fs_search tests
cargo test --package forge_services -- test_empty_file_type

# Run full test suites for affected crates
cargo test --package forge_json_repair
cargo test --package forge_services -- fs_search
cargo test --package forge_domain -- catalog

@github-actions github-actions Bot added the type: fix Iterations on existing features or infrastructure. label Feb 6, 2026
@amitksingh1490 amitksingh1490 merged commit e77a7f3 into main Feb 6, 2026
11 checks passed
@amitksingh1490 amitksingh1490 deleted the fs_search-gpt-5 branch February 6, 2026 08:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: fix Iterations on existing features or infrastructure.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant