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
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.
httpxto exercise key endpoints like/health,/providers, and/prompt.2. Type Hinting in
parse_json_outputThe
parse_json_outputfunction insrc/c3_invoke/output.pyacceptsNoneat runtime but is annotated to only acceptstr.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._handle_fallback()call in a try/except block to ensure.run()always returns aPromptResponse.4. Robustness in
GeminiProvider._handle_fallback()The fallback path in
GeminiProviderusessubprocess.run(check=True), which can raiseCalledProcessErrororTimeoutExpired._handle_fallbackand returnNoneto allow the caller to handle the failure gracefully.5. Support Dynamic Output Formats
Both
GeminiProviderandClaudeProvidercurrently hardcode the output format totext, ignoring theoutput_formatspecified inPromptRequest.build_command()in both providers to honorrequest.output_format.Ref: #1