Repository navigation
fix(jirapoll): treat an unparseable lastCheck as unset - #9852
7 commits merged into
Conversation
A lastCheck entity property that is not a timestamp made loadLastCheck return an error, so processIssue failed the issue on every pick and never saved a valid value. The activity filter keeps such an issue active, so when it was the only active candidate every quiet cycle ended in "all 1 selected issues failed to process". Treat a value that is not a JSON string holding an RFC 3339 timestamp as unset, as a future value already is. The issue gets one first-poll look bounded by the backfill window, which saves a valid lastCheck. Processing logs a WARNING naming the issue without the stored value, and the filter's per-cycle line names such candidates. A failed read is still an error. Amend ADR 0160 Decision item 1, which said the per-issue error path reports such a value, and update the Jira guide's security note. Fixes fullsend-ai#9766 Signed-off-by: guy oron <goron@redhat.com>
PR Summary by Qodofix(jirapoll): treat an unparseable lastCheck as unset
AI Description
Merge Risk
|
Code Review by Qodo
1. Accepted decision is changed without a successor record
|
Site previewPreview: https://64ff0410-site.fullsend-ai.workers.dev Commit: |
jflowers
left a comment
There was a problem hiding this comment.
Council review: fix(jirapoll): treat an unparseable lastCheck as unset
7/7 dispatched reviewers completed (adversary, architect, curator, fullsend, gaze-testing, guard, testing); the verdict reads APPROVE WITH ADVISORIES, with no CRITICAL or HIGH findings. Two MEDIUM test-coverage advisories and five LOW notes follow inline.
The core change holds up well: an unparseable lastCheck now follows the future-value path (unset, one backfill-window-bounded look, a valid checkpoint saved over the garbage), the stored value never reaches the logs, transport errors stay errors, and the issue stays active so an editor cannot hide it. lint.yml did not run at CI on this head (it triggers only on PRs to main); local runs on the head cover the gap: go build, affected-package tests with -race, and pre-commit on the changed files all pass.
Advisories worth a look before or soon after merge:
- the #9766 regression test drives only the time.Parse failure flavor; the json.Unmarshal branch (a JSON number or object as lastCheck) keeps no end-to-end pin, so a partial revert of that one branch passes the whole suite (MEDIUM)
- deleting TestRunGarbageLastCheckAloneFailsCycle leaves Run's all-selected-issues-failed guard (poller.go:190) with no direct coverage; the package's other two Run guards each keep a dedicated test (MEDIUM)
- the ADR 0160 Amendments section lands on a not-yet-merged ADR; docs/contributing/adrs.md prefers direct content edits while an ADR is in flight (LOW, two reviewers)
- the patch coverage gate (80/75) stays unverified on this head until the retarget to main (LOW)
- the saved-checkpoint assertion checks non-zero rather than the exact updated value (LOW)
This review was generated by /uf.review-pr (AI-assisted).
Review follow-up for the unparseable lastCheck fix. - TestRunGarbageLastCheckTreatedAsUnset runs a full cycle for each way a stored value can fail: a string that is not a time, JSON that is not a string, and bytes that are not JSON. The first only reaches the time.Parse branch; the other two reach the json.Unmarshal branch. - It asserts the saved lastCheck equals the issue's updated value instead of only being set. - TestRunAllSelectedIssuesFailedFailsCycle restores coverage of Run's all-failed guard, which the replaced test was the only one to reach. Signed-off-by: guy oron <goron@redhat.com>
jflowers
left a comment
There was a problem hiding this comment.
Verdict: APPROVE (light re-review)
Light check since 527843f, the commit carrying the prior review. The delta touches only tests: 1 file, 92 lines in internal/jirapoll/poller_idle_test.go.
Prior advisories: 4 of 7 resolved, 3 carried
Resolved by the delta:
poller_idle_test.go:399(parse flavor pin covered onlytime.Parse): the table now covers all threeclampInvalidinputs end to end (garbage string, JSON object, non-JSON), so thejson.Unmarshalflavor is pinned too.poller_idle_test.go:344(all-failed guard atpoller.go:190left uncovered):TestRunAllSelectedIssuesFailedFailsCycledrives a 503 property-get and asserts the "all 1 selected issues failed to process" error with 0 dispatches.poller_idle_test.go:344(clampInvalidvariants lacked a cycle-level test): all three cases run throughRunnow, asserting cycle 1 success, exactstoredLastCheckAt(...).Equal(updated), both log lines, and that the log never prints the stored value.poller_idle_test.go:356(IsZero()non-exact): assertions use exactEqual(updated)at line 368.
Carried (all LOW, tracked in the prior review's open threads):
- ADR 0160 uses an Amendments section on an ADR that has not merged yet, versus the direct-edit pattern of ADRs 0038 and 0070. The Status-line-conflict rationale is defensible; worth revisiting the placement at retarget?
- ADR 0160 Decision item 1 keeps its original wording.
lock.go:238patch coverage stays unverified until the retarget to main; the delta adds only test lines, which can only help coverage.
Checks
- CI: behaviour-github-emulator matrix, build, and DCO pass; other checks skipped as expected.
- Local: pre-commit pass on the 5 changed files;
go build ./...clean;go test -race -count=1 ./internal/jirapoll/ ./pkg/behaviourtest/drivers/jiramock/ok (1.390s / 1.506s).
Fixes #9766.
This review was generated by /uf.review-pr (AI-assisted).
|
@jflowers thanks for the review. The test follow-up is in c999cae:
On the ADR: 0160 is already on |
…seable-lastcheck Signed-off-by: guy oron <goron@redhat.com>
…seable-lastcheck Signed-off-by: guy oron <goron@redhat.com>
…lastcheck Signed-off-by: guy oron <goron@redhat.com>
|
🤖 Finished Review · ✅ Success · Started 9:39 AM UTC · Completed 9:48 AM UTC Commit: Runtime: pi · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $1.79 |
|
Risk Assessment: moderate (2/5) DetailsModerate risk: focused 123-line bug fix with full acceptance criteria coverage and test additions, balanced by elevated churn and coupling in the touched Jira poller components without feature-flag gating. |
|
Looks good to me |
|
Code review by qodo was updated up to the latest commit b3b6024 |
dhshah13
left a comment
There was a problem hiding this comment.
Validated on a local merge of b3b6024 into main (a5d0fb6): build, vet, go test -race for jirapoll and jiramock plus the Jira tests in cli, steps, poll, config and scaffold, and golangci-lint on the new lines all pass. Reverting either error branch, dropping either log line, or logging the stored value each fails a test. Independent review found no MEDIUM+ in the code.
Matches #9766. The amendment is the right form for an accepted ADR: 0160 has been on main since 1b2a002, and 0038 and 0070 carry the same section.
Non-blocking: no test tells "unset" from "floored to the window start" for a bad value. Flooring it still passes the package, and then an issue last updated more than a day ago stays idle with the bad value stored. One row in TestFilterLockedActivityDecision catches it:
{name: "JSON but not a time, updated 3 days ago", stored: json.RawMessage(`"yesterday"`), updated: now.Add(-72 * time.Hour).Format(jiraTimeLayout), active: true},CI (lint.yml, with the required semgrep) hasn't run on this PR. The base moved to main without a push, which fires only edited, so the next push starts it.
…ble-lastcheck Signed-off-by: guy oron <goron@redhat.com>
|
🤖 Finished Review · ✅ Success · Started 11:45 PM UTC · Completed 11:53 PM UTC Commit: Runtime: pi · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $1.48 |
waynesun09
left a comment
There was a problem hiding this comment.
One test-coverage finding, inline.
| } { | ||
| t.Run(tc.name, func(t *testing.T) { | ||
| now := time.Now().Truncate(time.Second) | ||
| updated := now.Add(-time.Hour) |
There was a problem hiding this comment.
MEDIUM: no test tells "treated as unset" apart from "floored to the window start" for an unparseable lastCheck
This test sets updated = now-1h for every case. The filterLocked table (lines 438-439) also puts its unparseable rows at updated = now-1h. Both values fall inside the 24h window.
Suppose an implementation kept clampInvalid and its log lines but set value = now-window, which is the clampFloor behaviour. The issue would still be active, get processed and store updated, so every current assertion would still pass.
The two behaviours differ only when updated is older than the window:
- Unset:
lc.value.IsZero()keeps the issue active, so it is visited and the garbage is overwritten. - Floor: the issue is idle, as in the "2020, updated 3 days ago" row (
active: false), and the garbage stays.
So no test pins the semantics described in the comment at lock.go:238-243 and in the ADR amendment. The earlier exact-value thread was fixed by the switch to Equal(updated), but that check still passes under a floor clamp.
Suggestion: add a filterLocked decision-table row with an unparseable stored value and updated = now-72h that expects active: true. Or add a Run case with updated = now-72h and a garbage lastCheck that asserts the issue is visited and storedLastCheckAt(...).Equal(updated).
Verified: read code at head (lock.go:238-252, poller.go:547-552, poller_idle_test.go:351-452); grep found no unparseable-value case with updated outside the window at 2ec3341; raised by: DeepSeek
There was a problem hiding this comment.
Agreed, it should go in before merge. This row passes on 2ec3341 and fails when the bad value is floored instead of treated as unset:
{name: "JSON but not a time, updated 3 days ago", stored: json.RawMessage(`"yesterday"`), updated: now.Add(-72 * time.Hour).Format(jiraTimeLayout), active: true},There was a problem hiding this comment.
This row covers the time.Parse branch (lock.go:253). Flooring only the json.Unmarshal branch (lock.go:246) still passes the package, because every row that reaches it has updated inside the window. One more row catches it:
{name: "not JSON, updated 3 days ago", stored: json.RawMessage(`not json`), updated: now.Add(-72 * time.Hour).Format(jiraTimeLayout), active: true},|
Risk Assessment: moderate (2/5) DetailsModerate risk: focused 123-line bug fix with full acceptance criteria coverage and test additions, balanced by elevated churn and coupling in the touched Jira poller components without feature-flag gating. |
|
Looks good to me Labels: Go bug fix in the Jira poller (internal/jirapoll) with an ADR amendment and doc update. |
Superseded by updated review
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Every unparseable row of the filter's decision table had updated one hour ago, inside the backfill window, where "treated as unset" and "floored to the window start" give the same answer. The new row has updated three days ago: unset keeps the issue active, while a floor would drop it and leave the bad value stored. Signed-off-by: guy oron <goron@redhat.com>
|
🤖 Finished Review · ✅ Success · Started 2:24 PM UTC · Completed 2:29 PM UTC Commit: Runtime: pi · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $0.78 |
|
Risk Assessment: moderate (2/5) DetailsModerate risk: focused 124-line bug fix with full acceptance criteria coverage and test additions, balanced by elevated churn and coupling in touched Jira poller components without feature-flag gating. |
|
Looks good to me |
Superseded by updated review
9c91c62
Summary
A
lastCheckentity property that is not a timestamp is now treated as unset, as a future value already is, instead of failing the issue on every pick. The issue gets one first-poll look bounded by the backfill window, which saves a validlastCheck, so a garbage value no longer turns every quiet cycle red.#9758, which this was stacked on, has merged, so the base is now
main. Jira: AISDLC-875.Related Issue
Fixes #9766
Changes
internal/jirapoll/lock.go:loadLastCheckreturns a newclampInvalid(value unset, stored value not kept) on a JSON or parse error instead of an error;readLastChecklogsWARNING: lastCheck for <KEY> is not a timestamp; treating as unsetwithout the stored value. A failed read (transport error) is still an error.internal/jirapoll/poller.go: the activity filter's one line per cycle also names these candidates (lastCheck not a timestamp, treated as unset: ...). They stay active, so an editor still cannot hide an issue by writing garbage.internal/jirapoll/poller_idle_test.go:TestRunGarbageLastCheckAloneFailsCycleasserted the old failure; it becomesTestRunGarbageLastCheckTreatedAsUnset, which runs for a string that is not a time, JSON that is not a string, and bytes that are not JSON: cycle 1 succeeds and saves the issue'supdatedvalue aslastCheckover the garbage, both log lines appear without the stored value, and cycle 2 skips the issue.TestRunAllSelectedIssuesFailedFailsCyclekeepsRun's all-failed guard covered. The filter decision table (not JSON, JSON but not a time, JSON number: all active) is unchanged and passes.docs/ADRs/0160-...md: an Amendments entry replacing Decision item 1's "the existing per-issue error path reports it as today", as Jira poller: an unparseable lastCheck fails every quiet poll cycle #9766 asks. ADR 0160 is Accepted and already onmain, so this is an edit to an accepted ADR: it is an appended amendment, as in ADRs 0038 and 0070, and it does not touch the Status lines ADR 0085 edits onmain.docs/guides/user/jira-integration.md: the security note and the active-candidate rule cover alastCheckthat is not a timestamp.TestFilterLockedActivityDecisiongains a row with a stored value that is not a timestamp andupdatedthree days old. It fails if such a value is floored to the window start instead of treated as unset. The earlier rows all hadupdatedinside the window, where the two give the same answer.Replay stays bounded by one backfill window, the same as deleting or forward-dating the property today.
Testing
make lintpasses (stage changes first, then run)All pass. The new test failed on
feat/jirapoll-skip-idle(#9758, since merged) without the fix (cycle 1: all 1 selected issues failed to process).Checklist
!for breaking changes)