Remove obsolete minor publish error

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

Co-authored-by: Bryan FRIMIN <bryan@frimin.fr>
This commit is contained in:
Cursor Agent
2026-05-26 02:31:26 +00:00
committed by Bryan Frimin
parent b721179974
commit 600aa6b8a8
11 changed files with 9 additions and 59 deletions

View File

@@ -75,9 +75,6 @@ type (
ErrDocumentArchived struct {
}
ErrCannotPublishMinorWithoutMajor struct {
}
ErrDocumentDraftNotDeletable struct {
}
@@ -252,10 +249,6 @@ func (e ErrDocumentArchived) Error() string {
return "cannot modify an archived document"
}
func (e ErrCannotPublishMinorWithoutMajor) Error() string {
return "cannot publish a minor version before a major version exists"
}
func (e ErrDocumentDraftNotDeletable) Error() string {
return "latest version is not a deletable draft"
}

View File

@@ -3028,10 +3028,9 @@ func formatRiskTreatment(t coredata.RiskTreatment) string {
// version. The version's Major, Minor, Status and PublishedAt fields are
// computed here based on the document's current published state, the minor
// flag, and whether approvers were provided. When minor is true the version
// is always published at currentMajor.(currentMinor+1) and approvers are
// ignored. When minor is false a non-empty approverIDs triggers an approval
// request at (currentMajor+1).0; otherwise the version is published at
// (currentMajor+1).0.
// is always published as a minor version and approvers are ignored. When
// minor is false a non-empty approverIDs triggers an approval request at
// (currentMajor+1).0; otherwise the version is published at (currentMajor+1).0.
func (s *GeneratedDocumentService) publishOrRequestApproval(
ctx context.Context, scope coredata.Scoper,
tx pg.Tx,
@@ -3057,12 +3056,14 @@ func (s *GeneratedDocumentService) publishOrRequestApproval(
}
if minor {
if document.CurrentPublishedMajor == nil || document.CurrentPublishedMinor == nil {
return &ErrCannotPublishMinorWithoutMajor{}
if document.CurrentPublishedMajor != nil && document.CurrentPublishedMinor != nil {
version.Major = *document.CurrentPublishedMajor
version.Minor = *document.CurrentPublishedMinor + 1
} else {
version.Major = 0
version.Minor = 1
}
version.Major = *document.CurrentPublishedMajor
version.Minor = *document.CurrentPublishedMinor + 1
version.Status = coredata.DocumentVersionStatusPublished
version.PublishedAt = &now
approverIDs = nil

View File

@@ -409,10 +409,6 @@ func (r *mutationResolver) PublishDataList(ctx context.Context, input types.Publ
return nil, gqlutils.Conflict(ctx, err)
}
if errMinor, ok := errors.AsType[*probo.ErrCannotPublishMinorWithoutMajor](err); ok {
return nil, gqlutils.Invalid(ctx, errMinor)
}
r.logger.ErrorCtx(ctx, "cannot publish data list", log.Error(err))
return nil, gqlutils.Internal(ctx)
@@ -437,10 +433,6 @@ func (r *mutationResolver) PublishAssetList(ctx context.Context, input types.Pub
return nil, gqlutils.Conflict(ctx, err)
}
if errMinor, ok := errors.AsType[*probo.ErrCannotPublishMinorWithoutMajor](err); ok {
return nil, gqlutils.Invalid(ctx, errMinor)
}
r.logger.ErrorCtx(ctx, "cannot publish asset list", log.Error(err))
return nil, gqlutils.Internal(ctx)

View File

@@ -693,10 +693,6 @@ func (r *mutationResolver) PublishFindingList(ctx context.Context, input types.P
return nil, gqlutils.Conflict(ctx, err)
}
if errMinor, ok := errors.AsType[*probo.ErrCannotPublishMinorWithoutMajor](err); ok {
return nil, gqlutils.Invalid(ctx, errMinor)
}
r.logger.ErrorCtx(ctx, "cannot publish finding list", log.Error(err))
return nil, gqlutils.Internal(ctx)

View File

@@ -785,10 +785,6 @@ func (r *mutationResolver) PublishStatementOfApplicability(ctx context.Context,
return nil, gqlutils.Conflict(ctx, err)
}
if errMinor, ok := errors.AsType[*probo.ErrCannotPublishMinorWithoutMajor](err); ok {
return nil, gqlutils.Invalid(ctx, errMinor)
}
r.logger.ErrorCtx(ctx, "cannot publish statement of applicability", log.Error(err))
return nil, gqlutils.Internal(ctx)

View File

@@ -280,10 +280,6 @@ func (r *mutationResolver) PublishDataProtectionImpactAssessmentList(ctx context
return nil, gqlutils.Conflict(ctx, err)
}
if errMinor, ok := errors.AsType[*probo.ErrCannotPublishMinorWithoutMajor](err); ok {
return nil, gqlutils.Invalid(ctx, errMinor)
}
r.logger.ErrorCtx(ctx, "cannot publish data protection impact assessment list", log.Error(err))
return nil, gqlutils.Internal(ctx)
@@ -308,10 +304,6 @@ func (r *mutationResolver) PublishTransferImpactAssessmentList(ctx context.Conte
return nil, gqlutils.Conflict(ctx, err)
}
if errMinor, ok := errors.AsType[*probo.ErrCannotPublishMinorWithoutMajor](err); ok {
return nil, gqlutils.Invalid(ctx, errMinor)
}
r.logger.ErrorCtx(ctx, "cannot publish transfer impact assessment list", log.Error(err))
return nil, gqlutils.Internal(ctx)

View File

@@ -1045,10 +1045,6 @@ func (r *mutationResolver) PublishDocument(ctx context.Context, input types.Publ
return nil, gqlutils.Conflict(ctx, errPending)
}
if errMinor, ok := errors.AsType[*probo.ErrCannotPublishMinorWithoutMajor](err); ok {
return nil, gqlutils.Invalid(ctx, errMinor)
}
if errContractEnded, ok := errors.AsType[*probo.ErrProfileContractEnded](err); ok {
return nil, gqlutils.Conflict(ctx, errContractEnded)
}

View File

@@ -125,10 +125,6 @@ func (r *mutationResolver) PublishObligationList(ctx context.Context, input type
return nil, gqlutils.Conflict(ctx, err)
}
if errMinor, ok := errors.AsType[*probo.ErrCannotPublishMinorWithoutMajor](err); ok {
return nil, gqlutils.Invalid(ctx, errMinor)
}
r.logger.ErrorCtx(ctx, "cannot publish obligation list", log.Error(err))
return nil, gqlutils.Internal(ctx)

View File

@@ -133,10 +133,6 @@ func (r *mutationResolver) PublishProcessingActivityList(ctx context.Context, in
return nil, gqlutils.Conflict(ctx, err)
}
if errMinor, ok := errors.AsType[*probo.ErrCannotPublishMinorWithoutMajor](err); ok {
return nil, gqlutils.Invalid(ctx, errMinor)
}
r.logger.ErrorCtx(ctx, "cannot publish processing activity list", log.Error(err))
return nil, gqlutils.Internal(ctx)

View File

@@ -246,10 +246,6 @@ func (r *mutationResolver) PublishRiskList(ctx context.Context, input types.Publ
return nil, gqlutils.Conflict(ctx, err)
}
if errMinor, ok := errors.AsType[*probo.ErrCannotPublishMinorWithoutMajor](err); ok {
return nil, gqlutils.Invalid(ctx, errMinor)
}
r.logger.ErrorCtx(ctx, "cannot publish risk list", log.Error(err))
return nil, gqlutils.Internal(ctx)

View File

@@ -581,10 +581,6 @@ func (r *mutationResolver) PublishThirdPartyList(ctx context.Context, input type
return nil, gqlutils.Conflict(ctx, err)
}
if errMinor, ok := errors.AsType[*probo.ErrCannotPublishMinorWithoutMajor](err); ok {
return nil, gqlutils.Invalid(ctx, errMinor)
}
r.logger.ErrorCtx(ctx, "cannot publish thirdParty list", log.Error(err))
return nil, gqlutils.Internal(ctx)