Skip to content

SessionStart hook exits 1 when last-run.json is absent (set -e + trailing && short-circuit) #440

@nipulchokshi-debug

Description

@nipulchokshi-debug

Summary

hooks/scripts/check-config.sh exits with status 1 on every Claude Code session start when ~/.config/last30days/last-run.json does not yet exist (i.e. the user has installed the plugin and completed setup, but hasn't run /last30days yet, or LAST30DAYS_CONFIG_DIR points somewhere without a last-run.json).

Claude Code surfaces this as:

SessionStart:startup hook error
Failed with non-blocking status code: No stderr output

…on every startup, even though the hook is functionally succeeding.

Root cause

The script has set -euo pipefail and ends with:

if [[ -n "$HAS_SCRAPECREATORS" ]]; then
  echo "/last30days: Ready — ${SOURCE_COUNT} sources active."
  echo "  Research any topic across social + market + web sources (last 30 days)."
  [[ -n "$LAST_RUN_LINE" ]] && echo "$LAST_RUN_LINE"
else
  ...
  [[ -n "$LAST_RUN_LINE" ]] && echo "$LAST_RUN_LINE"
  echo "  Tip: ..."
  echo "  ..."
  echo "  last30days has no affiliation with any API provider."
fi

In the if branch (ScrapeCreators configured), the last command executed is [[ -n "$LAST_RUN_LINE" ]] && echo "$LAST_RUN_LINE". When LAST_RUN_LINE is empty, the [[ ... ]] test fails, the short-circuit && skips the echo, and the script's final exit status becomes 1. set -e doesn't kill the script (an && chain in a compound statement is "tested"), but the script returns with $? = 1.

The else branch is fine because subsequent echo lines mask it.

Repro

  1. Install plugin (v3.2.4), complete setup so SCRAPECREATORS_API_KEY is set.
  2. Don't run /last30days (so no last-run.json).
  3. Start a new Claude Code session → "SessionStart:startup hook error".
$ bash hooks/scripts/check-config.sh; echo "exit=$?"
/last30days: Ready — 6 sources active.
  Research any topic across social + market + web sources (last 30 days).
exit=1

Fix

Append exit 0 at the end of the script, or replace the trailing test with one that doesn't poison $?:

if [[ -n "$LAST_RUN_LINE" ]]; then echo "$LAST_RUN_LINE"; fi

Happy to send a PR if useful.

Environment

  • macOS, /bin/bash 3.2
  • last30days-skill 3.2.4
  • Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions