Skip to content

fix(daemon): skip a stash event with no target oid instead of failing the side effect - #116

Merged
sagnik11 merged 1 commit into
mainfrom
posthog-self-driving/fixdaemon-skip-stash-pop-rewrite-when-1682fb
Nov 18, 2026
Merged

sagnik11 merged 1 commit into
mainfrom
posthog-self-driving/fixdaemon-skip-stash-pop-rewrite-when-1682fb

Conversation

@posthog

@posthog posthog Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Problem

  • When a stash pop, apply, branch, or drop has no resolvable target oid, the daemon fails the whole side effect. That stash's AI attribution is not carried over.
  • Each failure logs an error-level event with the sid in the message, so every occurrence opens a new error tracking issue.
  • On current main, a failed git stash pop on an empty stack always hits this. The terminal resolver correctly returns no target, and rewrite synthesis then returns a hard error. Git did nothing, but autter reports an error.
  • Older CLIs (2.2.1) hit it more often because they read the stash reflog while git was still running. fd62862 (v3.10.0) fixed that part.

Origin

  • Error tracking: issue 1, issue 2
  • First signal: 2026-11-18
  • Inbox report: open
  • Likely cause: fd62862
  • Task started by: auto-start, after the report was rated P3 and ready to fix

Changes

  • Rewrite synthesis now skips only the stash event that has no target oid. It does not fail the side effect.
    • Failed command (exit code not 0): debug log, because git changed nothing.
    • Successful command: warning log. Only this stash loses its attribution. Warnings do not go to error tracking.
  • The sid moves from the message into a structured field.
  • New integration test test_stash_pop_empty_stack_does_not_fail_daemon_side_effects: pops an empty stack before any stash, and again after a stash and pop, then commits AI lines and checks the attribution.
Case Before After
Failed pop/apply/branch/drop, no target Side effect fails, error event Event skipped, debug log
Successful pop/apply/branch/drop, no target Side effect fails, error event Event skipped, warning log
Target resolved Rewrite event No change

Note

A successful stash command with no target still loses that stash's attribution. This PR makes the failure contained and quiet. It does not recover the target.

Testing

  • The new test fails on main with the exact report error (stash Pop missing resolvable target oid) and passes with this change.
  • cargo test --test integration stash in daemon mode: 105 passed.
  • cargo test --lib stash: 21 passed.
  • rustfmt --check on the changed files and cargo clippy --all-targets -- -D warnings: clean.
  • I did not run the full task test suite or the wrapper-daemon mode.

Agent context

  • I did not change the history fallback in resolve_stash_sha_for_event. For a failed top-of-stack pop it can still pick a stale sha from rewrite history. That is a separate edge case and it does not cause this error.
  • I left the payload-time resolvers (resolve_stash_target_oid_for_terminal_payload and resolve_stash_target_oid_for_command) as they are. They log a different error, and the report does not cover them.

Created with PostHog Desktop from this inbox report.


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

… the side effect

A stash pop, apply, branch, or drop with no resolvable target oid returned a hard error from rewrite synthesis. That failed the whole side effect and logged an error-level event with the sid in the message. A failed pop on an empty stack always hit this.

Now the daemon skips only that stash event. A failed command logs at debug level, because git changed nothing. A successful command logs a warning. Add an integration test that pops an empty stack in daemon mode.

Generated-By: PostHog Desktop
Task-Id: e014bc24-9ad8-451b-8113-247b76d4543b
@posthog
posthog Bot requested a review from sagnik11 November 18, 2026 16:16
@sagnik11
sagnik11 marked this pull request as ready for review November 18, 2026 17:06
@sagnik11
sagnik11 merged commit 599ac81 into main Nov 18, 2026
8 checks passed
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