Harden subprocessor filters per review feedback
Address the review comments on the subprocessors work: - Reject invalid category/country filter values in the Subprocessors resolver with an INVALID error instead of relying solely on transport coercion, so a malformed request fails fast and explicitly. - Use pgx.StrictNamedArgs in the new distinct facet queries so missing or extra SQL placeholders stay detectable, matching sibling queries. - Default a nil ThirdPartyFilter at the service boundary to avoid a nil dereference in the coredata list/count paths. - Expose the category group label as an aria heading for assistive tech. - Add the missing space in the Select "Selected:" story label. Signed-off-by: Émile Ré <emile@probo.com>
This commit is contained in:
@@ -38,7 +38,7 @@ export function SubprocessorCategorySection({ category, subprocessors }: Subproc
|
||||
return (
|
||||
<section className="flex flex-col gap-4">
|
||||
<div className="flex flex-col gap-1">
|
||||
<Text size={3} weight="medium" color="neutral" highContrast>
|
||||
<Text size={3} weight="medium" color="neutral" highContrast role="heading" aria-level={2}>
|
||||
{t(`categories.${category}.label`)}
|
||||
</Text>
|
||||
<Text size={2} color="neutral">
|
||||
|
||||
@@ -87,6 +87,7 @@ export function Controlled() {
|
||||
</div>
|
||||
<span className="text-2 text-sand-11">
|
||||
Selected:
|
||||
{" "}
|
||||
{value ?? "none"}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@@ -800,7 +800,7 @@ ORDER BY
|
||||
`
|
||||
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||
|
||||
args := pgx.NamedArgs{"organization_id": organizationID}
|
||||
args := pgx.StrictNamedArgs{"organization_id": organizationID}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
|
||||
rows, err := conn.Query(ctx, q, args)
|
||||
@@ -836,7 +836,7 @@ ORDER BY
|
||||
`
|
||||
q = fmt.Sprintf(q, scope.SQLFragment())
|
||||
|
||||
args := pgx.NamedArgs{"organization_id": organizationID}
|
||||
args := pgx.StrictNamedArgs{"organization_id": organizationID}
|
||||
maps.Copy(args, scope.SQLArguments())
|
||||
|
||||
rows, err := conn.Query(ctx, q, args)
|
||||
|
||||
@@ -819,6 +819,14 @@ func (r *trustCenterResolver) Subprocessors(ctx context.Context, obj *types.Trus
|
||||
country = filter.Country
|
||||
}
|
||||
|
||||
if category != nil && !category.IsValid() {
|
||||
return nil, gqlutils.Invalidf(ctx, "invalid subprocessor category filter: %q", string(*category))
|
||||
}
|
||||
|
||||
if country != nil && !country.IsValid() {
|
||||
return nil, gqlutils.Invalidf(ctx, "invalid subprocessor country filter: %q", string(*country))
|
||||
}
|
||||
|
||||
showOnTrustCenter := true
|
||||
thirdPartyFilter := coredata.NewThirdPartyFilter(&showOnTrustCenter, nil, query, category, country)
|
||||
|
||||
|
||||
@@ -60,6 +60,10 @@ func (s ThirdPartyService) ListForOrganizationId(
|
||||
cursor *page.Cursor[coredata.ThirdPartyOrderField],
|
||||
filter *coredata.ThirdPartyFilter,
|
||||
) (*page.Page[*coredata.ThirdParty, coredata.ThirdPartyOrderField], error) {
|
||||
if filter == nil {
|
||||
filter = coredata.NewThirdPartyFilter(nil, nil, nil, nil, nil)
|
||||
}
|
||||
|
||||
var thirdParties coredata.ThirdParties
|
||||
|
||||
err := s.svc.pg.WithConn(
|
||||
|
||||
Reference in New Issue
Block a user