Skip to content

feat: Enhance error handling and result validation in CommandQueueCon…#183

Merged
rostilos merged 1 commit into
mainfrom
1.5.7-rc
May 22, 2026
Merged

feat: Enhance error handling and result validation in CommandQueueCon…#183
rostilos merged 1 commit into
mainfrom
1.5.7-rc

Conversation

@rostilos
Copy link
Copy Markdown
Owner

@rostilos rostilos commented May 22, 2026

…sumer and CommandService

Summary by CodeRabbit

  • Bug Fixes

    • Improved detection and handling of empty or invalid outputs from AI services in summarization and question-answering operations.
    • Enhanced error messaging to provide clearer feedback when AI operations return empty or malformed results.
  • Tests

    • Added comprehensive test coverage for result validation and error handling.

Review Change Stack

@rostilos rostilos merged commit 582f8d6 into main May 22, 2026
1 check was pending
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 22, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a5f46efa-ca26-4cf7-a9ac-de6f093fd396

📥 Commits

Reviewing files that changed from the base of the PR and between 7a2edbc and 647caf2.

📒 Files selected for processing (4)
  • python-ecosystem/inference-orchestrator/src/server/command_queue_consumer.py
  • python-ecosystem/inference-orchestrator/src/service/command/command_service.py
  • python-ecosystem/inference-orchestrator/tests/test_command_queue_consumer.py
  • python-ecosystem/inference-orchestrator/tests/test_command_service.py

📝 Walkthrough

Walkthrough

This PR adds comprehensive validation and error handling for AI service results in both the CommandService (upstream) and CommandQueueConsumer (downstream). Both services now detect empty/invalid outputs using a shared sentinel-string approach and normalize results before publishing. When a result is empty or malformed, the system publishes an error event instead of silently formatting invalid data.

Changes

Result Validation and Normalization Flow

Layer / File(s) Summary
CommandService validation helpers and constants
src/service/command/command_service.py
EMPTY_RESULT_SENTINELS sentinel set and normalization helpers (_normalize_summarize_result, _normalize_ask_result, _has_usable_text, _string_or_empty) detect empty outputs and normalize valid results for consistent handling.
CommandService process method integration
src/service/command/command_service.py
process_summarize and process_ask call normalization helpers after execution; empty/invalid results trigger early error events. Fallback error messages now return explicit "error": "AI service returned an empty summary/answer" strings.
CommandQueueConsumer validation helpers
src/server/command_queue_consumer.py
Mirror of service validation: EMPTY_RESULT_SENTINELS and helper methods (_has_error, _has_usable_text, _get_result_value, _string_or_empty) provide consistent result inspection.
CommandQueueConsumer event publishing integration
src/server/command_queue_consumer.py
Summarize/ask event publishing now validates summary/answer via _has_usable_text(), emits "error" events for empty results, and publishes final events only for successful outputs.
CommandService normalization unit tests
tests/test_command_service.py
TestNormalizeSummarizeResult and TestNormalizeAskResult suites verify error passthrough, non-dict rejection, empty-value rejection, and field defaulting for diagram and diagramType.
CommandQueueConsumer integration tests
tests/test_command_queue_consumer.py
FakeRedis test double and payload builders; four test cases verify that error/empty results trigger "error" events without final events, and successful results trigger final events without error events.

🐰 A bunny once fretted o'er empty responses
With sentinels guarding and handlers' compassion
Now errors ring clear, no silent missteps
From service to queue, the validation hops true 🚀

🎯 3 (Moderate) | ⏱️ ~20 minutes

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 1.5.7-rc

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant