Menu

#446 fix(intelligence): gate jira worklog backfill behind the sync cache

closed
nobody
None
2026-07-15
2026-07-15
Anonymous
No

Originally created by: Akarsh-Hegde

Summary

Fixes the critical CodeRabbit finding on PR [#440] (src/intelligence/providers/jira/mod.rs), split into its own PR because it reorders live daemon-sync logic and deserves review in isolation.

The bug

backfill_worklogged ran unconditionally at the top of refresh_if_stale, before the SYNC_INTERVAL_MINS (5 min) freshness check. A Jira ticket that has pm_worklogs rows but was permanently deleted/moved never comes back from fetch_by_keys, so it stays in the "missing" set forever. Result: on every poll tick, the daemon re-ran auth resolution + start-date-field discovery + an issue fetch for that dead ticket — a genuine rate-limit / ban hazard.

The fix

  • Move the backfill call into the cache-stale branch, after auth (ctx) and start_date_field are already resolved for the regular sync.
  • Pass that ctx + start_date_field into backfill_worklogged so it reuses them instead of re-resolving (removes the duplicate auth + field-discovery round-trips).

Net effect: a dead ticket is re-attempted at most once per sync cycle (same cadence as the regular sync), not once per tick. Still best-effort — a backfill failure never blocks the main sync.

Residual (documented, follow-up)

A dedicated tombstone column to stop re-fetching a confirmed-dead ticket entirely would remove even the once-per-cycle attempt, but needs its own schema change — left as follow-up. The gate alone removes the unbounded-per-tick hazard, which is the critical part.

Test plan

  • cargo build / cargo clippy -- -D warnings / cargo fmt --check: clean
  • cargo test --lib intelligence::providers::jira: 18 pass

🤖 Generated with Claude Code

Related

Tickets: #440
Tickets: #445
Tickets: #447

Discussion

  • Anonymous

    Anonymous - 2026-07-15

    Originally posted by: coderabbitai[bot]

    [!IMPORTANT]

    Review skipped

    Auto reviews are disabled on base/target branches other than the default branch.

    Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.


    ⚙️ Run configuration

    Configuration used: Organization UI

    Review profile: ASSERTIVE

    Plan: Pro Plus

    Run ID: 7b27f612-884d-408a-aa99-13c252835496

    You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

    Use the checkbox below for a quick retry:
    - [ ] 🔍 Trigger review

    ✨ Finishing Touches
    🧪 Generate unit tests (beta) - [ ] Create PR with unit tests - [ ] Commit unit tests in branch `fix/jira-backfill-rate-limit`

    Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

    ❤️ Share - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)

    Comment @coderabbitai help to get the list of available commands.

     
  • Anonymous

    Anonymous - 2026-07-15

    Ticket changed by: Akarsh-Hegde

    • status: open --> closed
     

Log in to post a comment.