Skip to content

fix: log _write_last_run failures instead of silent swallow#749

Open
23241a6749 wants to merge 1 commit into
mvanhorn:mainfrom
23241a6749:fix/write-last-run-silent-error
Open

fix: log _write_last_run failures instead of silent swallow#749
23241a6749 wants to merge 1 commit into
mvanhorn:mainfrom
23241a6749:fix/write-last-run-silent-error

Conversation

@23241a6749

Copy link
Copy Markdown
Contributor

Problem

_write_last_run() at last30days.py:723 silently swallowed all exceptions with except Exception: pass. Cache write failures — disk full, permission denied, serialization error, or a CONFIG_DIR file-path collision — were completely invisible, with no log, no stderr message, and no return value to the caller.

This made debugging report-cache issues impossible because the caller (main() at line 1385) could not distinguish cache written successfully from cache write failed silently.

Fix

Replace except Exception: pass with except Exception as exc: sys.stderr.write(...) that reports the failure to stderr using the same [last30days] prefix as other error messages in the file. The exception is not re-raised — cache writes are best-effort and should not interrupt the run.

Impact

Cache write failures are now visible on stderr. No behavior change on the success path. All existing tests continue to pass (they only exercise the success path).

The _write_last_run() function silently swallowed all exceptions with
'except Exception: pass'. Cache write failures (disk full, permissions,
serialization errors) were completely invisible — no log, no stderr
message, no metric. This made debugging report-cache issues impossible
because the caller could not distinguish 'cache written' from 'cache
write failed silently'.

Fix: log the exception message to stderr with the [last30days] prefix,
consistent with other error messages in the same file.
@greptile-apps

greptile-apps Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a silent exception swallow in _write_last_run() by logging cache-write failures to stderr instead of discarding them. The exception is still not re-raised, preserving the best-effort semantics of the cache write.

  • The one-line change in last30days.py replaces except Exception: pass with a sys.stderr.write(...) call that uses the existing [last30days] prefix convention; sys is already imported at line 14 so no new dependency is introduced.
  • The error path behavior is unchanged on success; on failure, callers and operators now have a visible signal instead of silent data loss.

Confidence Score: 5/5

Safe to merge — the change is a one-line observability improvement with no effect on the success path.

The diff touches only the failure branch of a best-effort cache write. sys was already imported, the message format matches existing conventions, and the exception is correctly not re-raised so callers are unaffected. No logic on the success path changed.

No files require special attention.

Important Files Changed

Filename Overview
skills/last30days/scripts/last30days.py Single-line fix: replaces silent except Exception: pass with a stderr log; sys is already imported, message format matches codebase conventions, and the exception is correctly not re-raised.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["_write_last_run(topic, report, entity_reports)"] --> B{CONFIG_DIR is None?}
    B -- Yes --> C[return early]
    B -- No --> D[mkdir target]
    D --> E[write last-run.json]
    E --> F[write last-report.json]
    F --> G[✅ cache written successfully]
    D -- exception --> H
    E -- exception --> H
    F -- exception --> H
    H["BEFORE: silent pass\nAFTER: sys.stderr.write(...)"] --> I["⚠️ log to stderr\n[last30days] Failed to write run cache: {exc}"]
    I --> J[return — run continues uninterrupted]
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A["_write_last_run(topic, report, entity_reports)"] --> B{CONFIG_DIR is None?}
    B -- Yes --> C[return early]
    B -- No --> D[mkdir target]
    D --> E[write last-run.json]
    E --> F[write last-report.json]
    F --> G[✅ cache written successfully]
    D -- exception --> H
    E -- exception --> H
    F -- exception --> H
    H["BEFORE: silent pass\nAFTER: sys.stderr.write(...)"] --> I["⚠️ log to stderr\n[last30days] Failed to write run cache: {exc}"]
    I --> J[return — run continues uninterrupted]
Loading

Reviews (1): Last reviewed commit: "fix: log _write_last_run failures instea..." | Re-trigger Greptile

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.

1 participant