Skip to content

docs(common): describe ErrRefusedBeforePurchase by its contract, not its producers #693

Open

Description

@cristim

Summary

common.ErrRefusedBeforePurchase (pkg/common/types.go) documents itself as wrapping errors from the approved-upfront check and the purchase-count bounds check. #538 adds a third producer: providers/azure/services/cache refuses every purchase because managedredis owns Azure Redis. The core contract still holds: if the sentinel is present, no purchase request was sent. But the doc's list of sources is now incomplete.

Current behaviour

A consumer that reads the doc can treat the sentinel as "upfront approval missing" and ask the user to approve and retry. For a cache refusal that retry can never succeed.

Steps to verify the gap

Call cache.Client.PurchaseCommitment with any recommendation. errors.Is(err, common.ErrRefusedBeforePurchase) is true, and the cause is ownership, not upfront approval.

Expected behaviour

The sentinel doc describes the contract in general terms (refused before the purchase request was built or sent), not as a list of the checks that use it. Callers that need to tell the causes apart have a way to do so.

Proposed fix

  • Reword the doc in pkg/common/types.go. Optionally add a distinct wrapped cause for an ownership refusal, so callers can tell it from the upfront check without matching text.
  • Then bump the pkg pin in providers/azure (and the other modules) in the same PR as any consumer that relies on it.

References

Parent: #538, and the PR that implements it (CHANGELOG Notices bullet). Raised in that PR's non-author review. Related: #673 (the sentinel).

Severity: low. It's documentation accuracy. The "nothing was sent" guarantee holds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions