Skip to content

Truncate long error messages#1182

Merged
rapids-bot[bot] merged 2 commits intoNVIDIA:developfrom
dagardner-nv:david-truncate-slack-messages
Nov 15, 2025
Merged

Truncate long error messages#1182
rapids-bot[bot] merged 2 commits intoNVIDIA:developfrom
dagardner-nv:david-truncate-slack-messages

Conversation

@dagardner-nv
Copy link
Contributor

@dagardner-nv dagardner-nv commented Nov 14, 2025

Description

  • Fixes an issue where test error messages can exceed the maximum length for slack messages.

By Submitting this PR I confirm:

  • I am familiar with the Contributing Guidelines.
  • We require that all contributors "sign-off" on their commits. This certifies that the contribution is your original work, or you have rights to submit it under the same license, or a compatible license.
    • Any contribution which contains commits that are not Signed-Off will not be accepted.
  • When the PR is ready for review, new or existing tests cover these changes.
  • When the PR is ready for review, the documentation is up to date with these changes.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed text truncation in Slack test report notifications so oversized messages are shortened (with "..." appended) and kept within the allowed length to prevent broken/oversized blocks.

Signed-off-by: David Gardner <dagardner@nvidia.com>
@dagardner-nv dagardner-nv self-assigned this Nov 14, 2025
@dagardner-nv dagardner-nv requested a review from a team as a code owner November 14, 2025 23:47
@dagardner-nv dagardner-nv added bug Something isn't working non-breaking Non-breaking change labels Nov 14, 2025
@coderabbitai
Copy link

coderabbitai bot commented Nov 14, 2025

Walkthrough

Adds a module-level constant to enforce a maximum text length limit of 3000 characters for Slack messages. The add_text function now truncates text exceeding this limit and appends an ellipsis indicator, with an assertion to verify the final length compliance.

Changes

Cohort / File(s) Summary
Text Length Limiting
ci/scripts/gitlab/report_test_results.py
Added MAX_TEXT_LENGTH = 3000 constant. Enhanced add_text to truncate oversized text, append "..." for truncation indication, and assert final length compliance.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Verify truncation logic correctly handles boundary cases (e.g., text exactly at MAX_TEXT_LENGTH, text just under the limit).
  • Confirm the "..." suffix is consistently appended and accounted for in the final length assertion.
  • Review unit/functional tests (if present) or consider adding tests for truncation behavior.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Truncate long error messages' clearly and concisely describes the main change - truncating text to prevent oversized Slack blocks, uses imperative mood, and is 28 characters well under the 72-character limit.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e412e86 and 3f91ded.

📒 Files selected for processing (1)
  • ci/scripts/gitlab/report_test_results.py (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • ci/scripts/gitlab/report_test_results.py

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.

Copy link

@coderabbitai coderabbitai bot left a comment

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 (1)
ci/scripts/gitlab/report_test_results.py (1)

101-101: Consider removing the redundant assertion.

The assertion on line 101 will always pass given the truncation logic on line 100. After truncation, the text length will be exactly MAX_TEXT_LENGTH (when truncated) or <= MAX_TEXT_LENGTH (when not truncated). This makes the assertion redundant.

Additionally, assertions can be disabled with Python's -O flag and are not intended for production validation. If runtime validation is needed, use a proper conditional check with error handling instead.

 def add_text(text: str, blocks: list[dict], plain_text: list[str]) -> None:
     if len(text) > MAX_TEXT_LENGTH:
         text = text[:(MAX_TEXT_LENGTH - 3)] + "..."
-    assert len(text) <= MAX_TEXT_LENGTH
     blocks.append(text_to_block(text))
     plain_text.append(text)
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cb53737 and e412e86.

📒 Files selected for processing (1)
  • ci/scripts/gitlab/report_test_results.py (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*

⚙️ CodeRabbit configuration file

**/*: # Code Review Instructions

  • Ensure the code follows best practices and coding standards. - For Python code, follow
    PEP 20 and
    PEP 8 for style guidelines.
  • Check for security vulnerabilities and potential issues. - Python methods should use type hints for all parameters and return values.
    Example:
    def my_function(param1: int, param2: str) -> bool:
        pass
  • For Python exception handling, ensure proper stack trace preservation:
    • When re-raising exceptions: use bare raise statements to maintain the original stack trace,
      and use logger.error() (not logger.exception()) to avoid duplicate stack trace output.
    • When catching and logging exceptions without re-raising: always use logger.exception()
      to capture the full stack trace information.

Documentation Review Instructions - Verify that documentation and comments are clear and comprehensive. - Verify that the documentation doesn't contain any TODOs, FIXMEs or placeholder text like "lorem ipsum". - Verify that the documentation doesn't contain any offensive or outdated terms. - Verify that documentation and comments are free of spelling mistakes, ensure the documentation doesn't contain any

words listed in the ci/vale/styles/config/vocabularies/nat/reject.txt file, words that might appear to be
spelling mistakes but are listed in the ci/vale/styles/config/vocabularies/nat/accept.txt file are OK.

Misc. - All code (except .mdc files that contain Cursor rules) should be licensed under the Apache License 2.0,

and should contain an Apache License 2.0 header comment at the top of each file.

  • Confirm that copyright years are up-to date whenever a file is changed.

Files:

  • ci/scripts/gitlab/report_test_results.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). (1)
  • GitHub Check: CI Pipeline / Check
🔇 Additional comments (1)
ci/scripts/gitlab/report_test_results.py (1)

26-27: No changes needed for the MAX_TEXT_LENGTH constant—verified correct per Slack API.

The constant value of 3,000 characters matches Slack's Block Kit API specification for section block text fields.

Signed-off-by: David Gardner <dagardner@nvidia.com>
@dagardner-nv
Copy link
Contributor Author

/merge

@rapids-bot rapids-bot bot merged commit 535afd9 into NVIDIA:develop Nov 15, 2025
17 checks passed
@dagardner-nv dagardner-nv deleted the david-truncate-slack-messages branch November 15, 2025 00:29
saglave pushed a commit to snps-scm13/SNPS-NeMo-Agent-Toolkit that referenced this pull request Dec 11, 2025
* Fixes an issue where test error messages can exceed the maximum length for slack messages.

## By Submitting this PR I confirm:
- I am familiar with the [Contributing Guidelines](https://github.com/NVIDIA/NeMo-Agent-Toolkit/blob/develop/docs/source/resources/contributing.md).
- We require that all contributors "sign-off" on their commits. This certifies that the contribution is your original work, or you have rights to submit it under the same license, or a compatible license.
  - Any contribution which contains commits that are not Signed-Off will not be accepted.
- When the PR is ready for review, new or existing tests cover these changes.
- When the PR is ready for review, the documentation is up to date with these changes.

## Summary by CodeRabbit

* **Bug Fixes**
  * Fixed text truncation in Slack test report notifications so oversized messages are shortened (with "..." appended) and kept within the allowed length to prevent broken/oversized blocks.

Authors:
  - David Gardner (https://github.com/dagardner-nv)

Approvers:
  - Anuradha Karuppiah (https://github.com/AnuradhaKaruppiah)

URL: NVIDIA#1182
Signed-off-by: Sangharsh Aglave <aglave@synopsys.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working non-breaking Non-breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants