Skip to content

fix(GKO-2863): return 400 when primary owner is a group member#17292

Open
benoitgravitee wants to merge 1 commit into
masterfrom
fix/GKO-2863-group-po-member-4xx
Open

fix(GKO-2863): return 400 when primary owner is a group member#17292
benoitgravitee wants to merge 1 commit into
masterfrom
fix/GKO-2863-group-po-member-4xx

Conversation

@benoitgravitee
Copy link
Copy Markdown
Contributor

@benoitgravitee benoitgravitee commented Jun 1, 2026

Issue

https://gravitee.atlassian.net/browse/GKO-2863

Summary

  • ImportGroupCRDUseCase now throws ValidationDomainException on severe validation errors (same pattern as other CRD import use cases), so the Automation API returns HTTP 400 instead of 500 when the org primary owner is listed as a group member.
  • Added a regression test reproducing the memory / admin member case from the ticket.

Test plan

  • mvn -f gravitee-apim-rest-api/gravitee-apim-rest-api-service/pom.xml test -Dtest=ImportGroupCRDUseCaseTest
  • PUT /automation/organizations/DEFAULT/environments/DEFAULT/groups with primary owner in members returns 400 and a message containing can not change the role of primary owner

@benoitgravitee benoitgravitee requested a review from a team as a code owner June 1, 2026 13:28
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@benoitgravitee benoitgravitee added the apply-on-4-12-x Mergify: apply on 4.12.x label Jun 2, 2026
@carlos-andres-osorio carlos-andres-osorio self-requested a review June 2, 2026 21:01
@benoitgravitee benoitgravitee force-pushed the fix/GKO-2863-group-po-member-4xx branch 2 times, most recently from fa34ac9 to 700fd65 Compare June 4, 2026 08:49
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Jun 4, 2026

ImportGroupCRDUseCase threw TechnicalDomainException on validation
failures, which the Automation API mapped to HTTP 500. Align with other
CRD import use cases and surface ValidationDomainException instead.

# Conflicts:
#	gravitee-apim-rest-api/gravitee-apim-rest-api-service/src/test/java/io/gravitee/apim/core/group/use_case/ImportGroupCRDUseCaseTest.java
@benoitgravitee benoitgravitee force-pushed the fix/GKO-2863-group-po-member-4xx branch from 700fd65 to fef9289 Compare June 4, 2026 12:24
@benoitgravitee benoitgravitee enabled auto-merge (rebase) June 4, 2026 12:25
var sanitizedInput = validationResult.value().orElseThrow(() -> new TechnicalDomainException("Unable to sanitize CRD spec"));
var sanitizedInput = validationResult.value().orElseThrow(() -> new ValidationDomainException("Unable to sanitize CRD spec"));

var status = queryService
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The update branch here (findById(...).map(existing -> update(...))) — the primary success path when the group already exists — has no test coverage. Both new tests exercise the validation/rejection paths only. A regression that broke group updates (e.g. creating a duplicate instead of updating the existing group) wouldn't be caught by CI.

This is a pre-existing gap rather than something this PR introduced, so feel free to treat it as out of scope — flagging it since the test class is already being touched here.

import static org.assertj.core.api.SoftAssertions.*;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: import static org.mockito.Mockito.when; is added here but the same import already exists on the next line, so this one is redundant. It compiles, but most spotless/checkstyle no-duplicate-import rules flag it.

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

Labels

apply-on-4-12-x Mergify: apply on 4.12.x

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants