Skip to content

Bug: /export-session crashes with ENOENT — export-html template assets shipped under wrong dist path #90843

Closed

Description

@Tank-x3

Summary

/export-session (alias /export) always fails with an ENOENT because the HTML template assets are shipped under a different dist/ path than the one the runtime resolves at execution time. The command is effectively broken in the published npm package.

Environment

  • OpenClaw 2026.6.1 (2e08f0f)
  • Node v24.12.0
  • Windows 11
  • Installed as a global npm package (%APPDATA%\npm\node_modules\openclaw)

What happens

Invoking /export-session from Discord produces this gateway error:

[discord] discord interaction handler failed: Error: ENOENT: no such file or directory, open
'C:\Users\kaker\AppData\Roaming\npm\node_modules\openclaw\dist\export-html\template.css'

Root cause

In the bundled runtime (dist/commands-handlers.runtime-*.js, from src/auto-reply/reply/commands-export-session.ts):

const EXPORT_HTML_DIR = path.join(path.dirname(fileURLToPath(import.meta.url)), "export-html");
async function loadTemplate(fileName) {
  return await fs.readFile(path.join(EXPORT_HTML_DIR, fileName), "utf-8");
}

import.meta.url for that bundle is at the dist/ root, so EXPORT_HTML_DIR resolves to dist/export-html. But the assets are not there.

Evidence

  • dist/export-html/ does not exist in the installed package.
  • The assets actually ship at dist/auto-reply/reply/export-html/:
    • template.html, template.css, template.js
    • vendor/marked.min.js, vendor/highlight.min.js

So loadTemplate("template.css") (and every other template file) throws ENOENT.

Repro

  1. Install OpenClaw 2026.6.1 globally via npm.
  2. Run /export-session on any session.
  3. Observe the ENOENT ...\dist\export-html\template.css error; no HTML is produced.

Suggested fix

Make the build place the export-html asset directory next to the runtime bundle that reads it (i.e. emit dist/export-html/), or change the path resolution in commands-export-session to point at the actual shipped location (dist/auto-reply/reply/export-html). Either way the source-relative asset path and the bundle-relative lookup need to agree.

Workaround

Copying the asset directory to the expected location restores the command (no restart needed, assets are read per-export):

dist/auto-reply/reply/export-html/  ->  dist/export-html/

Activity

  1. clawsweeper commented on Jun 6, 2026

    @clawsweeper
    Contributor

    Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed June 6, 2026, 12:24 AM ET / 04:24 UTC.

    Summary
    Keep open. The report matches current source and the published v2026.6.1 package layout: /export-session loads templates relative to the bundled runtime at dist/export-html, while the build copies them to dist/auto-reply/reply/export-html, so the latest shipped command can fail before producing HTML.

    Reproducibility: yes. there is a high-confidence source/package reproduction path: install v2026.6.1 and run /export-session, where the bundle reads dist/export-html/template.css but the package ships the assets under dist/auto-reply/reply/export-html. I did not execute the live channel command during this read-only review.

    Next step
    This is a narrow, current, shipped bug with clear likely files and a focused validation path, so it is a good manually promoted repair candidate.

    Review details

    Best possible solution:

    Align the runtime template lookup and packaged asset copy path, then add a packaging-focused regression check so future builds prove the bundle can read the shipped templates.

    Do we have a high-confidence way to reproduce the issue?

    Yes, there is a high-confidence source/package reproduction path: install v2026.6.1 and run /export-session, where the bundle reads dist/export-html/template.css but the package ships the assets under dist/auto-reply/reply/export-html. I did not execute the live channel command during this read-only review.

    Is this the best way to solve the issue?

    Yes, the best fix is a narrow packaging/runtime alignment plus regression coverage for the packaged path. A broad export-session refactor or workaround copy by users is not needed for this specific bug.

    AGENTS.md: found and applied where relevant.

    Remaining risk / open question:

    • I did not run a live Discord /export-session command in this read-only review; the high-confidence proof is from current source plus the published package layout.

    Codex review notes: model gpt-5.5, reasoning high; reviewed against 8e9c377971bb.

    Label changes

    Label changes:

    • add P2: The latest release appears to break a documented owner slash command, but the impact is limited to HTML session export rather than core runtime availability.
    • add impact:other: The issue affects a maintainer-visible export command path that does not fit the more specific data-loss, security, session-state, auth-provider, message-loss, or crash-loop labels.
    • add issue-rating: 🦞 diamond lobster: Current issue advisory state selects this label.
    • add clawsweeper:source-repro: Current issue advisory state selects this label.
    • add clawsweeper:queueable-fix: Current issue advisory state selects this label.
    • add clawsweeper:fix-shape-clear: Current issue advisory state selects this label.

    Label justifications:

    • P2: The latest release appears to break a documented owner slash command, but the impact is limited to HTML session export rather than core runtime availability.
    • impact:other: The issue affects a maintainer-visible export command path that does not fit the more specific data-loss, security, session-state, auth-provider, message-loss, or crash-loop labels.
    Evidence reviewed

    Acceptance criteria:

    • node scripts/run-vitest.mjs src/auto-reply/reply/commands-export-session.test.ts test/scripts/build-all.test.ts
    • Run a package/build artifact check that confirms the built runtime lookup path contains the export-html assets before publishing.
    • If build output or package layout changes, run pnpm build or the repo-approved remote/Testbox equivalent before handoff.

    What I checked:

    • Current runtime lookup: buildExportSessionReply loads template.html, template.css, template.js, and vendor files from path.dirname(fileURLToPath(import.meta.url))/export-html, which is bundle-relative after tsdown output. (src/auto-reply/reply/commands-export-session.ts:23, 8e9c377971bb)
    • Command entry path: /export-session and /export are dispatched through handleExportSessionCommand, so this template lookup is on the documented slash-command path. (src/auto-reply/reply/commands-info.ts:293, 8e9c377971bb)
    • Build copies assets elsewhere: The export template copy script targets dist/auto-reply/reply/export-html, and the build step cache records that same output path rather than dist/export-html. (scripts/copy-export-html-templates.ts:19, 8e9c377971bb)
    • Shipped v2026.6.1 package proof: The v2026.6.1 npm tarball contains package/dist/auto-reply/reply/export-html/template.css and the other template assets, has no package/dist/export-html/ entries, and its commands-handlers.runtime-CtnEUSKY.js still computes EXPORT_HTML_DIR as dirname(import.meta.url)/export-html. (2e08f0f4221f)
    • Coverage gap: The command unit test mocks template reads by suffix and uses source-adjacent files, while the build test only asserts the copy step label; neither checks that the packaged runtime lookup path and copied asset path agree. (src/auto-reply/reply/commands-export-session.test.ts:85, 8e9c377971bb)
    • Related search: Public GitHub search found this issue as the only exact export-session ENOENT export-html report; adjacent export-html issues exist but do not supersede this packaging-path bug.

    Likely related people:

    • boris721: Authored the merged /export-session PR and the bundled-template commit that added src/auto-reply/reply/commands-export-session.ts and scripts/copy-export-html-templates.ts. (role: introduced behavior; confidence: high; commits: 4cc75b057178, 33fd271a8b35, f82a3d3e2bb4; files: src/auto-reply/reply/commands-export-session.ts, scripts/copy-export-html-templates.ts, src/auto-reply/reply/export-html/template.css)
    • Alix-007: Authored the recent merged export-html robustness fix for the template runtime, so they have recent context on the HTML export surface even though this issue is about packaging paths. (role: recent adjacent contributor; confidence: medium; commits: 2a4aaef6d967, efa0bec9ae2b, 5811693c7fce; files: src/auto-reply/reply/export-html/template.js, src/auto-reply/reply/export-html/template.security.test.ts)
    • Ayaan Zaidi: The shallow local checkout blames the current exported-session source and build-copy paths to the grafted current-main commit, but deeper ownership is better represented by the merged PR metadata above. (role: current snapshot committer; confidence: low; commits: 520992a1defd; files: src/auto-reply/reply/commands-export-session.ts, scripts/copy-export-html-templates.ts, scripts/build-all.mjs)
    How this review workflow works
    • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
    • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
    • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
    • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
    • Maintainers can also comment @clawsweeper review to request a fresh review only.
    • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
    • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
    • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
  2. added
    P2Normal backlog priority with limited blast radius.
    impact:otherThis issue has meaningful maintainer-visible impact outside the owned taxonomy.
    issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.
    clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.
    clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.
    clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.
    on Jun 6, 2026
  3. LiuwqGit commented on Jun 6, 2026

    @LiuwqGit
    Contributor

    Fix submitted

    PR: #90873

    Summary

    Fixed the export-html template copy path mismatch that caused /export-session to fail with ENOENT.

    Root cause: Templates were copied to dist/auto-reply/reply/export-html/ but the runtime bundle (at dist/ root) resolves the path as dist/export-html/.

    Changes:

    • Updated scripts/copy-export-html-templates.ts to copy to dist/export-html/
    • Updated scripts/build-all.mjs cache configuration to match
    • Added verification test for runtime path resolution

    Verification

    • ✅ Templates now correctly copied to dist/export-html/
    • ✅ All required template files present
    • ✅ Path verification test passes

    This fix restores the /export-session command functionality for npm package users.

    Co-Authored-By: nebulacoder-v8.0 noreply@zte.com.cn

  4. self-assigned this
    on Jun 6, 2026
  5. added a commit that references this issue on Jun 6, 2026
    09d6479
  6. added a commit that references this issue on Jun 7, 2026
    6bcff8a
  7. locked as resolved and limited conversation to collaborators on Jun 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P2Normal backlog priority with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:otherThis issue has meaningful maintainer-visible impact outside the owned taxonomy.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions