Skip to content

test: reproduce subscription item history overlap - #5250

Closed
turip wants to merge 1 commit into
mainfrom
feat/subscription-item-history-overlap-repro
Closed

turip wants to merge 1 commit into
mainfrom
feat/subscription-item-history-overlap-repro

Conversation

@turip

@turip turip commented Oct 5, 2026 •

Copy link
Copy Markdown
Member

When the same item on a running subscription is replaced twice at the same effective time through the API, the database stores the original revision, a zero-duration intermediate revision, and the current revision. That history is valid and remains relevant for an in-advance flat fee with proration disabled.

If the current revision is read before the zero-duration revision, the subscription view incorrectly treats the history as overlapping and rejects it. This pull request adds an API-driven, database-backed test that reproduces that failure.

RetriggerConfidence Score: 4/5

The PR is not ready to merge because the new test still rejects the valid revision history it is intended to cover.

Fix All in Claude CodeFindings

  1. P1 New test cannot pass ▶
Fix with agent prompt
### Issue 1
test/subscription/item_history_overlap_test.go:undefined-183
When the test puts the open-ended revision before the zero-duration revision, `NewSubscriptionView` reports `subscription item history overlap`. The test therefore fails at `require.NoError`, leaving the PostgreSQL-backed subscription test suite failing. The second `EditRunning` call may fail earlier if the repository returns those revisions in the same order.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

Adds a PostgreSQL-backed test for two same-time replacements of a subscription item and the resulting three-revision history.

  • Persists an original revision, a zero-duration intermediate revision, and a current revision.
  • Passes a deterministic read order to the subscription view to reproduce the overlap rejection.
Diagram
sequenceDiagram
    participant Client as API client
    participant Workflow as Subscription workflow
    participant DB as PostgreSQL
    participant View as Subscription view
    Client->>Workflow: Replace item at T (remove + add)
    Workflow->>DB: Persist original [start, T) and first replacement [T, ∞)
    Client->>Workflow: Replace same item again at T (remove + add)
    Workflow->>DB: Persist intermediate [T, T) and current [T, ∞)
    DB-->>View: Read original, current, intermediate
    View-->>Client: Reject history as overlapping
Loading

Reviews (2) · Last reviewed commit: "test: reproduce subscription item histor..."

@coderabbitai

coderabbitai Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

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

nil,
)

require.NoError(t, err)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 New test cannot pass

When the test puts the open-ended revision before the zero-duration revision, NewSubscriptionView reports subscription item history overlap. The test therefore fails at require.NoError, leaving the PostgreSQL-backed subscription test suite failing. The second EditRunning call may fail earlier if the repository returns those revisions in the same order.

Prompt To Fix With AI
This is a comment left during a code review.
Path: test/subscription/item_history_overlap_test.go
Line: 183

Comment:
**New test cannot pass**

When the test puts the open-ended revision before the zero-duration revision, `NewSubscriptionView` reports `subscription item history overlap`. The test therefore fails at `require.NoError`, leaving the PostgreSQL-backed subscription test suite failing. The second `EditRunning` call may fail earlier if the repository returns those revisions in the same order.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Claude Code Fix in Codex

@turip

turip commented Oct 5, 2026

Copy link
Copy Markdown
Member Author

@greptileai please regenerate the sequence diagram for this reproduction and add it to the PR summary. Show the two same-time API item replacements, the persisted original, zero-duration, and current revisions, the observed read order, and the subscription view rejecting the history as overlapping.

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