Skip to content

test: resolve Slack proof OpenClaw root#4043

Merged
jyaunches merged 2 commits into
NVIDIA:mainfrom
jyaunches:fix/slack-proof-openclaw-root
May 22, 2026
Merged

test: resolve Slack proof OpenClaw root#4043
jyaunches merged 2 commits into
NVIDIA:mainfrom
jyaunches:fix/slack-proof-openclaw-root

Conversation

@jyaunches

@jyaunches jyaunches commented May 22, 2026

Copy link
Copy Markdown
Contributor

Summary

  • make the M-S17 Slack channel @mention proof resolve OpenClaw from more than fixed global install paths
  • discover the package root via OPENCLAW_PACKAGE_ROOT, npm root -g, require.resolve, the openclaw executable, and bounded filesystem lookup
  • log the resolved Slack test API root when found to improve future E2E diagnostics

Why

Recent messaging-providers E2E runs intermittently fail M-S17 with:

OpenClaw Slack test API not found in: /tmp/npm-global/lib/node_modules/openclaw, /usr/local/lib/node_modules/openclaw

Passing runs show the same UNDICI-EHPA warnings, so the warnings are noise; the real flake is path-layout discovery for dist/extensions/slack/test-api.js.

Validation

  • bash -n test/e2e/lib/slack-api-proof.sh test/e2e/test-messaging-providers.sh
  • git diff --check

Related evidence

  • Run 26262708948: M-S17 failed with missing OpenClaw Slack test API
  • Runs 26260886472 and 26261117406: same intermittent signature
  • Run 26261748162: same warnings but M-S17 passed

Summary by CodeRabbit

  • Tests
    • Improved internal Slack API test tooling: broadened runtime-root discovery, expanded lookup paths for the test artifact, de-duplicated candidate selection to avoid repeats, and clearer failure messages when the test artifact cannot be located.

Note: This release contains no user-facing changes.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 22, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 24333b6d-e5e0-4ca5-8112-09faa7f9348e

📥 Commits

Reviewing files that changed from the base of the PR and between b1fb339 and 4f2f892.

📒 Files selected for processing (1)
  • test/e2e/lib/slack-api-proof.sh

📝 Walkthrough

Walkthrough

Updated the Slack API proof test helper's embedded Node.js module to add createRequire and refactor resolveOpenClawRoot to build a normalized, de-duplicated candidate set using multiple discovery strategies, then validate candidates by checking for dist/extensions/slack/test-api.js.

Changes

OpenClaw Root Discovery Enhancement

Layer / File(s) Summary
OpenClaw root discovery with multi-strategy candidates
test/e2e/lib/slack-api-proof.sh
Added createRequire import and rewrote resolveOpenClawRoot to build a de-duplicated candidate list using a Set with normalized absolute paths. Candidates are discovered via: environment variable OPENCLAW_PACKAGE_ROOT, global npm root -g, require.resolve on OpenClaw's package.json, directory walking from a discovered openclaw binary (following symlinks), filesystem find under common roots, and additional hardcoded module locations. Each candidate is validated by checking for the existence of dist/extensions/slack/test-api.js, and an error lists attempted candidates if none match.

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested Labels

Integration: OpenClaw, fix

Suggested Reviewers

  • cv

Poem

🐰 A little rabbit hops through path and root,

Chasing symlinks, npm roots, and resolv'd paths astute,
Gathering candidates in a tidy Set so neat,
Until the Slack test API is found beneath our feet,
Hooray — our proof helper's discovery is complete!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ 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%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: resolving the OpenClaw root for the Slack proof test module, which directly addresses the core problem of intermittent E2E failures due to fixed global install paths.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@jyaunches jyaunches force-pushed the fix/slack-proof-openclaw-root branch from c41dbdd to 04e7d0a Compare May 22, 2026 02:14
@copy-pr-bot

copy-pr-bot Bot commented May 22, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@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

🤖 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

📥 Commits

Reviewing files that changed from the base of the PR and between c41dbdd and 04e7d0a.

📒 Files selected for processing (1)
  • test/e2e/lib/slack-api-proof.sh

Comment thread test/e2e/lib/slack-api-proof.sh
@jyaunches jyaunches force-pushed the fix/slack-proof-openclaw-root branch from 04e7d0a to b1fb339 Compare May 22, 2026 02:23

@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.

♻️ Duplicate comments (1)
test/e2e/lib/slack-api-proof.sh (1)

214-221: ⚠️ Potential issue | 🟠 Major

Filter nonexistent find roots before invoking execFileSync.

This fallback still passes /usr/local, /tmp/npm-global, and /sandbox unconditionally. If one start directory is missing, GNU find can print a valid match from another root and still exit non-zero; execFileSync then throws, and the empty catch {} 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: stdout contains a matching test-api.js path while find_exit_status is 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

📥 Commits

Reviewing files that changed from the base of the PR and between 04e7d0a and b1fb339.

📒 Files selected for processing (1)
  • test/e2e/lib/slack-api-proof.sh

@jyaunches jyaunches merged commit 9130d10 into NVIDIA:main May 22, 2026
20 checks passed
@wscurran wscurran added the chore Build, CI, dependency, or tooling maintenance label Jun 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Build, CI, dependency, or tooling maintenance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants