test: resolve Slack proof OpenClaw root#4043
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughUpdated the Slack API proof test helper's embedded Node.js module to add ChangesOpenClaw Root Discovery Enhancement
Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested Labels
Suggested Reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
c41dbdd to
04e7d0a
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@test/e2e/lib/slack-api-proof.sh`:
- Around line 214-221: resolveOpenClawRoot currently calls execFileSync with
multiple start directories and swallows any thrown error, which lets GNU find's
non-zero exit (due to missing start dirs) skip OpenClaw discovery; modify the
logic in resolveOpenClawRoot so that you only pass existing start directories to
execFileSync (filter the array ["/usr/local", "/tmp/npm-global", "/sandbox"]
with fs.existsSync before calling find), or else run find separately per
candidate root and collect the first successful match, and ensure any thrown
error still allows other candidates to be tried before returning; keep the
addCandidate(path.resolve(discovered, "../../../..")) usage unchanged.
🪄 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: c89f1052-dc11-4edb-be76-2c7ff8d04e6c
📒 Files selected for processing (1)
test/e2e/lib/slack-api-proof.sh
04e7d0a to
b1fb339
Compare
There was a problem hiding this comment.
♻️ Duplicate comments (1)
test/e2e/lib/slack-api-proof.sh (1)
214-221:⚠️ Potential issue | 🟠 MajorFilter nonexistent
findroots before invokingexecFileSync.This fallback still passes
/usr/local,/tmp/npm-global, and/sandboxunconditionally. If one start directory is missing, GNUfindcan print a valid match from another root and still exit non-zero;execFileSyncthen throws, and the emptycatch {}drops the discovered path. That means the flaky M-S17 failure can still survive in the new fallback.Suggested fix
try { - const discovered = execFileSync( - "find", - ["/usr/local", "/tmp/npm-global", "/sandbox", "-path", "*/dist/extensions/slack/test-api.js", "-print", "-quit"], - { encoding: "utf8" }, - ).trim(); + const searchRoots = ["/usr/local", "/tmp/npm-global", "/sandbox"].filter((root) => fs.existsSync(root)); + const discovered = searchRoots.length + ? execFileSync( + "find", + [...searchRoots, "-path", "*/dist/extensions/slack/test-api.js", "-print", "-quit"], + { encoding: "utf8" }, + ).trim() + : ""; if (discovered) addCandidate(path.resolve(discovered, "../../../..")); } catch {}Run this to verify the failure mode still exists and that the current code at Line 214-Line 221 is using unconditional roots:
#!/bin/bash set -euo pipefail python3 - <<'PY' from pathlib import Path p = Path("test/e2e/lib/slack-api-proof.sh") lines = p.read_text(encoding="utf-8", errors="replace").splitlines() for i in range(214, 222): print(f"{i:4d}: {lines[i-1]}") PY tmpdir="$(mktemp -d)" mkdir -p "$tmpdir/openclaw/dist/extensions/slack" touch "$tmpdir/openclaw/dist/extensions/slack/test-api.js" missing="$tmpdir/does-not-exist" set +e find "$missing" "$tmpdir" -path '*/dist/extensions/slack/test-api.js' -print -quit > /tmp/find.out 2> /tmp/find.err status=$? set -e echo "find_exit_status=$status" echo "--- stdout ---" cat /tmp/find.out echo "--- stderr ---" cat /tmp/find.err rm -rf "$tmpdir"Expected result:
stdoutcontains a matchingtest-api.jspath whilefind_exit_statusis non-zero. In that case,execFileSync(...).trim()would throw instead of returning the discovered path.🤖 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 `@test/e2e/lib/slack-api-proof.sh` around lines 214 - 221, The fallback unconditionally passes roots to execFileSync which can cause find to exit non-zero if any root is missing; update the try block around execFileSync to first filter the roots array (e.g. ["/usr/local","/tmp/npm-global","/sandbox"]) using fs.existsSync or fs.statSync so only existing directories are passed, and only call execFileSync when the filtered list is non-empty; keep using discovered and addCandidate(path.resolve(...)) as before and preserve the existing try/catch behavior but avoid swallowing a valid discovered path by ensuring execFileSync isn't invoked with missing roots.
🤖 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.
Duplicate comments:
In `@test/e2e/lib/slack-api-proof.sh`:
- Around line 214-221: The fallback unconditionally passes roots to execFileSync
which can cause find to exit non-zero if any root is missing; update the try
block around execFileSync to first filter the roots array (e.g.
["/usr/local","/tmp/npm-global","/sandbox"]) using fs.existsSync or fs.statSync
so only existing directories are passed, and only call execFileSync when the
filtered list is non-empty; keep using discovered and
addCandidate(path.resolve(...)) as before and preserve the existing try/catch
behavior but avoid swallowing a valid discovered path by ensuring execFileSync
isn't invoked with missing roots.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 57c56f8d-dfda-4c53-bf97-d6bbd0e72cd3
📒 Files selected for processing (1)
test/e2e/lib/slack-api-proof.sh
Summary
OPENCLAW_PACKAGE_ROOT,npm root -g,require.resolve, theopenclawexecutable, and bounded filesystem lookupWhy
Recent messaging-providers E2E runs intermittently fail M-S17 with:
Passing runs show the same
UNDICI-EHPAwarnings, so the warnings are noise; the real flake is path-layout discovery fordist/extensions/slack/test-api.js.Validation
bash -n test/e2e/lib/slack-api-proof.sh test/e2e/test-messaging-providers.shgit diff --checkRelated evidence
Summary by CodeRabbit
Note: This release contains no user-facing changes.