Skip to content

fix: config.LOGS_DIR honors CCXRAY_HOME (banner + legacy migration)#50

Merged
lis186 merged 1 commit into
mainfrom
fix/config-logs-dir-ccxray-home
Jun 6, 2026
Merged

fix: config.LOGS_DIR honors CCXRAY_HOME (banner + legacy migration)#50
lis186 merged 1 commit into
mainfrom
fix/config-logs-dir-ccxray-home

Conversation

@lis186

@lis186 lis186 commented Jun 6, 2026

Copy link
Copy Markdown
Owner

Closes #31.

Problem

server/config.js hardcoded LOGS_DIR = ~/.ccxray/logs, ignoring CCXRAY_HOME even though the storage layer (server/storage/index.js) resolved it correctly. With CCXRAY_HOME set, config.LOGS_DIR — used by the startup banner and the one-time legacy-logs migration — pointed at the wrong directory.

Root cause

The logs path was computed independently in two places, so they drifted.

Fix

  • New server/paths.js as single source of truth: resolveCcxrayHome() / resolveLogsDir(), precedence LOGS_DIR > CCXRAY_HOME > ~/.ccxray/logs (mirrors the storage layer's historical resolution exactly).
  • config.js and storage/index.js both resolve from it → banner + migration target can no longer drift from where logs are written.
  • Banner is now backend-aware: each storage adapter exposes a display-only location (local logs dir, or s3://bucket/prefix), so S3 setups stop showing a misleading local path.

Tests

  • runSnippet now sanitizes CCXRAY_HOME/LOGS_DIR/STORAGE_BACKEND so ambient shell/hub env can't corrupt results.
  • New cases: CCXRAY_HOME honored, LOGS_DIR precedence, default fallback (HOME+USERPROFILE pinned to temp, cross-platform), and an end-to-end write proving config.storage lands files under config.LOGS_DIR (no drift).
  • Full suite: 772/772.

Reviewed

Codex (gpt-5.5, xhigh) — no blockers; two minor polish items applied (cross-platform HOME pinning, honest paths.js comment).

Not in this PR (tracked separately)

  • hub.js, settings.js, ratelimit-log.js, auth.js still duplicate the CCXRAY_HOME home-dir resolution inline — candidates for consolidation into paths.js. Kept out to keep this PR focused on config.LOGS_DIR does not honor CCXRAY_HOME (banner + legacy migration use wrong path) #31.
  • S3 banner / legacy-migration target have no direct automated test (no bug found; S3 live-banner smoke is blocked by the optional @aws-sdk/client-s3 not being installed in dev).

server/config.js hardcoded LOGS_DIR to ~/.ccxray/logs, ignoring CCXRAY_HOME
while the storage layer resolved it correctly. This left config.LOGS_DIR
(used by the startup banner and the one-time legacy-logs migration) pointing
at the wrong directory whenever CCXRAY_HOME was set.

Root cause was a duplicated path computation. Introduce server/paths.js as the
single source of truth (resolveCcxrayHome/resolveLogsDir, precedence
LOGS_DIR > CCXRAY_HOME > ~/.ccxray/logs) and have both config.js and
storage/index.js resolve from it, so the banner and migration target can no
longer drift from where logs are actually written.

Also make the startup banner backend-aware: each storage adapter now exposes a
display-only 'location' (local logs dir, or s3://bucket/prefix), so S3 setups
no longer show a misleading local path.

Tests: sanitize CCXRAY_HOME/LOGS_DIR/STORAGE_BACKEND in the config test child
env, and add coverage for CCXRAY_HOME resolution, LOGS_DIR precedence, default
fallback (HOME/USERPROFILE pinned), and storage-write/​config drift.

Closes #31
@lis186 lis186 merged commit 993dc33 into main Jun 6, 2026
2 checks passed
@lis186 lis186 deleted the fix/config-logs-dir-ccxray-home branch June 6, 2026 05:14
lis186 added a commit that referenced this pull request Jun 6, 2026
hub.js, settings.js, ratelimit-log.js, and auth.js each inlined the same
'process.env.CCXRAY_HOME || path.join(os.homedir(), ".ccxray")' expression.
Replace all four with resolveCcxrayHome() from server/paths.js (introduced in
#50), and drop the now-unused 'os' import in each. auth.js keeps the call
inside getHubDir() so it still reads the env per call.

Pure de-duplication — identical behavior, no precedence change. The
CCXRAY_HOME contract is now enforced in one place, so it can't drift the way
config.LOGS_DIR did in #31.

Closes #51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

config.LOGS_DIR does not honor CCXRAY_HOME (banner + legacy migration use wrong path)

1 participant