diff --git a/apps/console/src/pages/organizations/compliance-page/_components/CompliancePageAliasField.tsx b/apps/console/src/pages/organizations/compliance-page/_components/CompliancePageAliasField.tsx index a49816d47..07a7effc6 100644 --- a/apps/console/src/pages/organizations/compliance-page/_components/CompliancePageAliasField.tsx +++ b/apps/console/src/pages/organizations/compliance-page/_components/CompliancePageAliasField.tsx @@ -80,32 +80,37 @@ export function CompliancePageAliasField(props: { return; } - if (trimmed === "") { - if (current !== "" && canRemoveAlias) { - await removeTrustCenterAlias({ - variables: { - input: { - resourceId, + try { + if (trimmed === "") { + if (current !== "" && canRemoveAlias) { + await removeTrustCenterAlias({ + variables: { + input: { + resourceId, + }, }, - }, - }); + }); + } + + return; } - return; - } + if (!canSetAlias) { + setValue(current); + return; + } - if (!canSetAlias) { - return; - } - - await setTrustCenterAlias({ - variables: { - input: { - resourceId, - alias: trimmed, + await setTrustCenterAlias({ + variables: { + input: { + resourceId, + alias: trimmed, + }, }, - }, - }); + }); + } catch { + // useMutationWithToasts already shows an error toast. + } }, [alias, canRemoveAlias, canSetAlias, removeTrustCenterAlias, resourceId, setTrustCenterAlias, value]); const canEdit = canSetAlias || (canRemoveAlias && (alias ?? "") !== ""); diff --git a/pkg/server/api/console/v1/audit_resolvers.go b/pkg/server/api/console/v1/audit_resolvers.go index 55ec3f879..848333e51 100644 --- a/pkg/server/api/console/v1/audit_resolvers.go +++ b/pkg/server/api/console/v1/audit_resolvers.go @@ -180,7 +180,13 @@ func (r *auditResolver) Alias(ctx context.Context, obj *types.Audit) (*string, e return nil, err } - return r.probo.TrustCenterAliases.GetByResourceID(ctx, scope, obj.ID) + alias, err := r.probo.TrustCenterAliases.GetByResourceID(ctx, scope, obj.ID) + if err != nil { + r.logger.ErrorCtx(ctx, "cannot get audit alias", log.Error(err)) + return nil, gqlutils.Internal(ctx) + } + + return alias, nil } // Permission is the resolver for the permission field. diff --git a/pkg/trust/compliance_page_service.go b/pkg/trust/compliance_page_service.go index 99260d1d1..267ff7145 100644 --- a/pkg/trust/compliance_page_service.go +++ b/pkg/trust/compliance_page_service.go @@ -240,8 +240,18 @@ func (s *Service) RenderRobotsTxt( } func (s *Service) fetchDocumentIDs(ctx context.Context, scope coredata.Scoper, orgID gid.GID) ([]string, error) { + seen := make(map[gid.GID]struct{}) var resourceIDs []gid.GID + appendResourceID := func(id gid.GID) { + if _, ok := seen[id]; ok { + return + } + + seen[id] = struct{}{} + resourceIDs = append(resourceIDs, id) + } + var cursorKey *page.CursorKey for { cursor := page.NewCursor( @@ -264,7 +274,7 @@ func (s *Service) fetchDocumentIDs(ctx context.Context, scope coredata.Scoper, o continue } - resourceIDs = append(resourceIDs, doc.ID) + appendResourceID(doc.ID) } if !result.Info.HasNext { @@ -304,7 +314,7 @@ func (s *Service) fetchDocumentIDs(ctx context.Context, scope coredata.Scoper, o continue } - resourceIDs = append(resourceIDs, file.ID) + appendResourceID(file.ID) } if !result.Info.HasNext { @@ -342,7 +352,7 @@ func (s *Service) fetchDocumentIDs(ctx context.Context, scope coredata.Scoper, o continue } - resourceIDs = append(resourceIDs, *audit.ReportFileID) + appendResourceID(*audit.ReportFileID) } if !result.Info.HasNext {