Skip to content

Address feedback from PR #1 review #2

Description

@lasalasa

The initial review of Pull Request #1 has identified several areas for improvement and potential bug fixes. This issue tracks the resolution of these points:

1. Test Coverage for FastAPI Server

The new FastAPI server surface (app factory + routers) lacks test coverage.

  • Action: Add integration tests using httpx to exercise key endpoints like /health, /providers, and /prompt.

2. Type Hinting in parse_json_output

The parse_json_output function in src/c3_invoke/output.py accepts None at runtime but is annotated to only accept str.

  • Action: Update the signature to def parse_json_output(output: str | None) -> Any:.

3. Exception Guarding in BaseProvider.run()

BaseProvider.run() calls _handle_fallback() without guarding against exceptions that the fallback itself might raise.

  • Action: Wrap the _handle_fallback() call in a try/except block to ensure .run() always returns a PromptResponse.

4. Robustness in GeminiProvider._handle_fallback()

The fallback path in GeminiProvider uses subprocess.run(check=True), which can raise CalledProcessError or TimeoutExpired.

  • Action: Catch these exceptions within _handle_fallback and return None to allow the caller to handle the failure gracefully.

5. Support Dynamic Output Formats

Both GeminiProvider and ClaudeProvider currently hardcode the output format to text, ignoring the output_format specified in PromptRequest.

  • Action: Update build_command() in both providers to honor request.output_format.

Ref: #1

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions