Skip to content

fix(secops): ensure consistent string return types in security tools - #313

Open
dandye wants to merge 1 commit into
mainfrom
fix/issue-161-security-tools-return-types
Open

fix(secops): ensure consistent string return types in security tools#313
dandye wants to merge 1 commit into
mainfrom
fix/issue-161-security-tools-return-types

Conversation

@dandye

@dandye dandye commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator

Summary

Resolves #161:

  • Enforces the -> str return type contract in get_threat_intel by ensuring non-string or nested dictionary/list responses from the Gemini model are serialized with json.dumps().
  • Corrects a copy-paste error in do_update_security_alert exception handling ("retrieving" -> "updating").
  • Updates integration test assertions in test_secops_mcp.py to match the str (JSON-encoded) return types of get_security_alert_by_id and do_update_security_alert.
  • Adds hermetic unit test coverage:
    • server/secops/tests/test_threat_intel_unit.py: 7 tests covering GeminiResponse objects, block formats, string answers, nested dictionary answers, direct string responses, unexpected response formats, and error handling.
    • server/secops/tests/test_security_alerts_unit.py: 6 additional tests covering get_security_alerts empty/error paths, get_security_alert_by_id success/error paths, and do_update_security_alert success/error paths.

Fixes #161


Verification

  • Hermetic Unit Tests:
    Ran full test suite in server/secops:

    uv run --directory server/secops --extra test pytest tests/test_security_alerts_unit.py tests/test_threat_intel_unit.py tests/test_secops_tools_unit.py tests/test_secops_parser_management_unit.py

    Result: 38 passed in 1.45s

  • Linter & Formatting:

    uvx ruff check tests/test_security_alerts_unit.py tests/test_threat_intel_unit.py
    uvx ruff format --check tests/test_security_alerts_unit.py tests/test_threat_intel_unit.py

    Result: All checks passed.

- Ensure get_threat_intel always returns str when answer is non-string or nested dict
- Fix copy-paste typo in do_update_security_alert error message
- Update test_secops_mcp assertions to match str/json return types
- Add unit tests for threat_intel and security alert return type serialization

Fixes #161
@dandye
dandye requested a review from a team September 9, 2026 02:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix return type inconsistencies in security tools

1 participant