Truncate long error messages#1182
Conversation
Signed-off-by: David Gardner <dagardner@nvidia.com>
WalkthroughAdds a module-level constant to enforce a maximum text length limit of 3000 characters for Slack messages. The Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
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. Comment |
There was a problem hiding this comment.
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
-Oflag 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
📒 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
raisestatements to maintain the original stack trace,
and uselogger.error()(notlogger.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.txtfile, words that might appear to be
spelling mistakes but are listed in theci/vale/styles/config/vocabularies/nat/accept.txtfile 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>
|
/merge |
* 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>
Description
By Submitting this PR I confirm:
Summary by CodeRabbit