Skip to content

Show better error message if eval uses invalid tags - #774

Merged
aantn merged 4 commits into
masterfrom
better-error-message-bad-tags
Aug 5, 2025
Merged

aantn merged 4 commits into
masterfrom
better-error-message-bad-tags

Conversation

@aantn

@aantn aantn commented Aug 3, 2025

Copy link
Copy Markdown
Collaborator

No description provided.

@aantn
aantn requested a review from moshemorad August 3, 2025 10:38
@coderabbitai

coderabbitai Bot commented Aug 3, 2025 •

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@aantn has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 7 minutes and 49 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between e71c375 and 447d545.

📒 Files selected for processing (2)
  • tests/llm/conftest.py (1 hunks)
  • tests/llm/utils/test_case_utils.py (3 hunks)

Walkthrough

The update enhances error handling in the validation process for AskHolmesTestCase instances within the test utilities. When a Pydantic validation error occurs, the code now checks for literal type mismatches in the tags field, prints detailed error information if found, and then re-raises the original error. Additionally, the Braintrust URL printed in a test fixture is made dynamic by retrieving it via a function instead of using a hardcoded string.

Changes

Cohort / File(s) Change Summary
Enhanced Validation Error Handling
tests/llm/utils/test_case_utils.py
Adds logic to inspect Pydantic ValidationError for literal mismatches in tags, prints details, and re-raises error.
Dynamic Braintrust URL in Test Fixture
tests/llm/conftest.py
Updates printed Braintrust URL message in llm_availability_check fixture to use dynamic URL from get_braintrust_url() instead of hardcoded string.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~7 minutes

Possibly related PRs

  • add tags to failing tests #597: Adds explicit error handling for validation errors related to the tags field in AskHolmesTestCase instances, introducing new tags and updating allowed tags constants and test case metadata; closely related to tag validation logic in test utilities.

Suggested reviewers

  • arikalon1
  • moshemorad
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch better-error-message-bad-tags

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (3)
tests/llm/utils/test_case_utils.py (3)

155-155: Fix typo in error message.

There's a grammatical error in the error message.

-                            error_msg += f"Allowed tags; {get_allowed_tags_list()}"
+                            error_msg += f"Allowed tags: {get_allowed_tags_list()}"

148-148: Handle different input types more robustly.

The error["input"] might not always be a string tag - it could be a list, None, or other types depending on the validation error.

-                                problematic_tags.append(error["input"])
+                                input_value = error["input"]
+                                if isinstance(input_value, list):
+                                    problematic_tags.extend(str(tag) for tag in input_value)
+                                else:
+                                    problematic_tags.append(str(input_value))

This ensures the error message remains clear regardless of the input type.


138-157: Consider extracting error handling logic for better maintainability.

The enhanced error handling works correctly but adds complexity to an already large method. For better maintainability and potential reuse, consider extracting this logic to a helper function.

def _handle_validation_error_with_tag_details(
    e: ValidationError, test_case_folder: Path
) -> None:
    """Handle ValidationError and print detailed tag error information if applicable."""
    problematic_tags = []
    for error in e.errors():
        if error["type"] == "literal_error" and len(error["loc"]) > 0 and error["loc"][-1] == "tags":
            input_value = error["input"]
            if isinstance(input_value, list):
                problematic_tags.extend(str(tag) for tag in input_value)
            else:
                problematic_tags.append(str(input_value))
    
    if problematic_tags:
        error_msg = f"VALIDATION ERROR in test case: {test_case_folder.name}\n"
        error_msg += f"Problematic tags: {', '.join(problematic_tags)}\n"
        error_msg += f"Allowed tags: {get_allowed_tags_list()}"
        print(error_msg)

Then use it in the except block:

except ValidationError as e:
    _handle_validation_error_with_tag_details(e, test_case_folder)
    raise e
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fb0b2f6 and 17322d6.

📒 Files selected for processing (1)
  • tests/llm/utils/test_case_utils.py (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

📄 CodeRabbit Inference Engine (CLAUDE.md)

**/*.py: ALWAYS place Python imports at the top of the file, not inside functions or methods
Use Ruff for formatting and linting (configured in pyproject.toml)
Type hints required (mypy configuration in pyproject.toml)

Files:

  • tests/llm/utils/test_case_utils.py
🧠 Learnings (3)
📓 Common learnings
Learnt from: nherment
PR: robusta-dev/holmesgpt#610
File: .github/workflows/llm-evaluation.yaml:39-42
Timestamp: 2025-07-08T08:45:41.069Z
Learning: The robusta-dev/holmesgpt codebase has comprehensive existing validation for Azure environment variables (AZURE_API_BASE, AZURE_API_KEY, AZURE_API_VERSION) and MODEL in tests/llm/utils/classifiers.py, tests/llm/conftest.py, and holmes/core/llm.py. Don't suggest adding redundant validation logic.
Learnt from: nherment
PR: robusta-dev/holmesgpt#610
File: .github/workflows/llm-evaluation.yaml:39-42
Timestamp: 2025-07-08T08:45:41.069Z
Learning: When suggesting improvements to environment variable handling in robusta-dev/holmesgpt, check first if validation logic already exists rather than reimplementing it.
Learnt from: nherment
PR: robusta-dev/holmesgpt#436
File: tests/llm/utils/mock_utils.py:240-249
Timestamp: 2025-06-05T12:23:27.634Z
Learning: The holmesgpt project uses Python >= 3.10 and prefers modern type hint syntax like `list[str]`, `dict[str, int]` over importing equivalent types from the typing module like `List[str]`, `Dict[str, int]`.
📚 Learning: the robusta-dev/holmesgpt codebase has comprehensive existing validation for azure environment varia...
Learnt from: nherment
PR: robusta-dev/holmesgpt#610
File: .github/workflows/llm-evaluation.yaml:39-42
Timestamp: 2025-07-08T08:45:41.069Z
Learning: The robusta-dev/holmesgpt codebase has comprehensive existing validation for Azure environment variables (AZURE_API_BASE, AZURE_API_KEY, AZURE_API_VERSION) and MODEL in tests/llm/utils/classifiers.py, tests/llm/conftest.py, and holmes/core/llm.py. Don't suggest adding redundant validation logic.

Applied to files:

  • tests/llm/utils/test_case_utils.py
📚 Learning: in llm-as-judge test cases for holmesgpt, expected outputs should be descriptive rather than prescri...
Learnt from: Sheeproid
PR: robusta-dev/holmesgpt#586
File: tests/llm/fixtures/test_ask_holmes/03_what_is_the_command_to_port_forward/test_case.yaml:4-4
Timestamp: 2025-07-02T10:27:17.231Z
Learning: In LLM-as-judge test cases for HolmesGPT, expected outputs should be descriptive rather than prescriptive when testing for flexible responses like port numbers. Using specific values in expected outputs can cause unnecessary test failures when the AI generates different but equally valid responses.

Applied to files:

  • tests/llm/utils/test_case_utils.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: llm_evals
  • GitHub Check: Pre-commit checks
  • GitHub Check: Pre-commit checks
🔇 Additional comments (2)
tests/llm/utils/test_case_utils.py (2)

11-11: LGTM!

The ValidationError import is correctly added and necessary for the enhanced error handling.


16-16: LGTM!

The get_allowed_tags_list import is correctly added and used appropriately in the error handling logic.

Comment thread tests/llm/utils/test_case_utils.py Outdated
moshemorad
moshemorad previously approved these changes Aug 3, 2025
@aantn
aantn enabled auto-merge (squash) August 3, 2025 11:26
@aantn
aantn requested a review from moshemorad August 5, 2025 10:05
@github-actions

github-actions Bot commented Aug 5, 2025

Copy link
Copy Markdown
Contributor

Results of HolmesGPT evals

  • ask_holmes: 26/41 test cases were successful, 0 regressions, 1 skipped, 14 mock failures
Test suite Test case Status
ask 01_how_many_pods ✅
ask 02_what_is_wrong_with_pod 🔧
ask 03_what_is_the_command_to_port_forward 🔧
ask 04_related_k8s_events ↪️
ask 05_image_version 🔧
ask 09_crashpod ✅
ask 10_image_pull_backoff 🔧
ask 11_init_containers ✅
ask 14_pending_resources ✅
ask 15_failed_readiness_probe 🔧
ask 17_oom_kill ✅
ask 18_crash_looping_v2 ✅
ask 19_detect_missing_app_details 🔧
ask 24_misconfigured_pvc 🔧
ask 28_permissions_error ✅
ask 29_events_from_alert_manager ✅
ask 39_failed_toolset 🔧
ask 41_setup_argo ✅
ask 42_dns_issues_steps_new_tools 🔧
ask 43_current_datetime_from_prompt ✅
ask 45_fetch_deployment_logs_simple ✅
ask 51_logs_summarize_errors 🔧
ask 53_logs_find_term ✅
ask 54_not_truncated_when_getting_pods 🔧
ask 59_label_based_counting ✅
ask 60_count_less_than 🔧
ask 61_exact_match_counting ✅
ask 63_fetch_error_logs_no_errors ✅
ask 77_liveness_probe_misconfiguration 🔧
ask 79_configmap_mount_issue 🔧
ask 83_secret_not_found 🔧
ask 86_configmap_like_but_secret 🔧
ask 88_affinity_like_but_taints 🔧
ask 89_runbook_missing_cloudwatch 🔧
ask 90_runbook_basic_selection 🔧
ask 93_calling_datadog ✅
ask 93_calling_datadog ✅
ask 93_calling_datadog ✅
ask 100_historical_logs 🔧
ask 24a_misconfigured_pvc_basic 🔧
ask 13a_pending_node_selector_basic 🔧

Legend

  • ✅ the test was successful
  • ↪️ the test was skipped
  • ⚠️ the test failed but is known to be flaky or known to fail
  • 🔧 the test failed due to mock data issues (not a code regression)
  • ❌ the test failed and should be fixed before merging the PR

@aantn
aantn merged commit 383805a into master Aug 5, 2025
@aantn
aantn deleted the better-error-message-bad-tags branch August 5, 2025 10:17
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.

2 participants