fix(examples): exit non-zero on count_tasks.sh error paths#298
Conversation
📝 WalkthroughWalkthroughThe task-counting shell script now uses stricter Bash error handling, defaults a missing ChangesTask-counting error handling
Estimated code review effort: 1 (Trivial) | ~2 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
examples/load-tests/tasks/count_tasks.sh (1)
16-19: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick winEnable strict shell mode safely. Use
set -euo pipefailand read the org id withORG_ID=${1:-}so missing arguments still hit the existingorg id is requiredcheck instead of aborting on$1.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@examples/load-tests/tasks/count_tasks.sh` around lines 16 - 19, Update the shell script’s strict-mode setup to use set -euo pipefail, and change the positional argument assignment to default missing $1 to an empty value via ORG_ID=${1:-}. Preserve the existing org-id-required validation so omitted arguments reach that check instead of causing an unset-parameter failure.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@examples/load-tests/tasks/count_tasks.sh`:
- Around line 22-31: Add regression tests for count_tasks.sh covering invocation
without ORG_ID and invocation when ngc is unavailable, asserting exit status 1
for both failure paths. Use the repository’s native shell-test framework and
ensure the ngc test isolates or mocks command -v behavior; run the native test
runner before committing, or document the reason for omission in the pull
request description.
---
Outside diff comments:
In `@examples/load-tests/tasks/count_tasks.sh`:
- Around line 16-19: Update the shell script’s strict-mode setup to use set -euo
pipefail, and change the positional argument assignment to default missing $1 to
an empty value via ORG_ID=${1:-}. Preserve the existing org-id-required
validation so omitted arguments reach that check instead of causing an
unset-parameter failure.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 427fad65-a4c6-4b2a-9e75-899d27dbd4f9
📒 Files selected for processing (1)
examples/load-tests/tasks/count_tasks.sh
Both error paths used a bare exit, which returns the status of the preceding echo, so the script exited 0 when the org id was missing or the ngc CLI was absent. Use exit 1 like clear_all_tasks.sh does. Also enable set -euo pipefail per the examples shell style and read the org id with a default so the missing-argument case still reaches the existing check. Closes NVIDIA#297 Signed-off-by: mesutoezdil <mesudozdil@gmail.com>
791cfc3 to
6247fac
Compare
TL;DR
Both error paths used a bare exit, so the script returned 0 when the org id was missing or ngc was absent. Now exit 1, matching clear_all_tasks.sh, plus set -euo pipefail and ORG_ID=${1:-} per the examples shell style. Both failure paths verified to exit 1; example script with no test harness.
Issues
Closes #297