Use sentinel errors for campaign validation failures

Follow the cookiebanner pattern: grouped var Err* sentinels in the
service package, wrapped with fmt.Errorf where context is needed, and
explicit errors.Is checks in GraphQL resolvers.

Signed-off-by: Cursor Agent <cursoragent@cursor.com>

Co-authored-by: Bryan FRIMIN <bryan@frimin.fr>
This commit is contained in:
Cursor Agent
2026-07-20 15:41:29 +00:00
parent a2b29b3d80
commit 0870e1dd15
4 changed files with 46 additions and 192 deletions

View File

@@ -724,7 +724,7 @@ func (r *mutationResolver) CreateAccessReviewCampaign(ctx context.Context, input
},
)
if err != nil {
if accessreview.IsCampaignClientError(err) {
if errors.Is(err, accessreview.ErrCampaignSourceOrganizationMismatch) {
return nil, gqlutils.Invalid(ctx, err)
}
@@ -760,7 +760,8 @@ func (r *mutationResolver) UpdateAccessReviewCampaign(ctx context.Context, input
return nil, gqlutils.NotFound(ctx, err)
}
if accessreview.IsCampaignClientError(err) {
if errors.Is(err, accessreview.ErrCampaignNotDraft) ||
errors.Is(err, accessreview.ErrCampaignSourceOrganizationMismatch) {
return nil, gqlutils.Invalid(ctx, err)
}
@@ -805,7 +806,8 @@ func (r *mutationResolver) StartAccessReviewCampaign(ctx context.Context, input
campaign, err := r.accessReview.StartCampaign(ctx, scope, input.AccessReviewCampaignID)
if err != nil {
if accessreview.IsCampaignClientError(err) {
if errors.Is(err, accessreview.ErrCampaignNoScopeSources) ||
errors.Is(err, accessreview.ErrCampaignNotDraft) {
return nil, gqlutils.Invalid(ctx, err)
}