mirror of
https://github.com/affaan-m/everything-claude-code.git
synced 2026-04-23 10:33:32 +08:00
review: broaden CLAUDE_TRANSCRIPT_PATH fallback to cover missing/empty JSON fields
Previously the env fallback ran only when JSON.parse threw. If stdin was valid JSON but omitted transcript_path or provided a non-string/empty value, the script dropped to the getSessionIdShort() fallback path, re-introducing the collision this PR targets. Validate the parsed transcript_path and apply the env-var fallback for any unusable value, not just malformed JSON. Matches coderabbit's outside-diff suggestion and keeps both input-source paths equivalent. Refs #1494
This commit is contained in:
@@ -179,14 +179,22 @@ function mergeSessionHeader(content, today, currentTime, metadata) {
|
||||
}
|
||||
|
||||
async function main() {
|
||||
// Parse stdin JSON to get transcript_path
|
||||
// Parse stdin JSON to get transcript_path; fall back to env var on missing,
|
||||
// empty, or non-string values as well as on malformed JSON.
|
||||
let transcriptPath = null;
|
||||
try {
|
||||
const input = JSON.parse(stdinData);
|
||||
transcriptPath = input.transcript_path;
|
||||
if (input && typeof input.transcript_path === 'string' && input.transcript_path.length > 0) {
|
||||
transcriptPath = input.transcript_path;
|
||||
}
|
||||
} catch {
|
||||
// Fallback: try env var for backwards compatibility
|
||||
transcriptPath = process.env.CLAUDE_TRANSCRIPT_PATH;
|
||||
// Malformed stdin: fall through to the env-var fallback below.
|
||||
}
|
||||
if (!transcriptPath) {
|
||||
const envTranscriptPath = process.env.CLAUDE_TRANSCRIPT_PATH;
|
||||
if (typeof envTranscriptPath === 'string' && envTranscriptPath.length > 0) {
|
||||
transcriptPath = envTranscriptPath;
|
||||
}
|
||||
}
|
||||
|
||||
const sessionsDir = getSessionsDir();
|
||||
|
||||
Reference in New Issue
Block a user