alibaba/COLA · warning · BizException
B_CUSTOMER_companyNameConflict
B_CUSTOMER_companyNameConflict
Error message
公司名冲突
What it means
Same company-name conflict guard as the service archetype: CustomerAddCmdExe.execute throws BizException with code B_CUSTOMER_companyNameConflict (via ErrorCode.getErrCode()) and message "公司名冲突" when the DTO's companyName equals "ConflictCompanyName". This is the web archetype's sample duplicate check.
Source
Thrown at cola-archetypes/cola-archetype-web/src/main/resources/archetype-resources/__rootArtifactId__-app/src/main/java/customer/executor/CustomerAddCmdExe.java:21
#set( $symbol_escape = '\' )
package ${package}.customer.executor;
import com.alibaba.cola.dto.Response;
import com.alibaba.cola.exception.BizException;
import ${package}.dto.CustomerAddCmd;
import ${package}.dto.data.ErrorCode;
import org.springframework.stereotype.Component;
@Component
public class CustomerAddCmdExe{
public Response execute(CustomerAddCmd cmd) {
//The flow of usecase is defined here.
//The core ablility should be implemented in Domain. or sink to Domian gradually
if(cmd.getCustomerDTO().getCompanyName().equals("ConflictCompanyName")){
throw new BizException(ErrorCode.B_CUSTOMER_companyNameConflict.getErrCode(), "公司名冲突");
}
return Response.buildSuccess();
}
}
View on GitHub (pinned to 352e1a8675)
Solutions
- Submit a companyName other than "ConflictCompanyName".
- Replace the hard-coded check with a real database uniqueness validation before adding the customer.
- Add exception handling (e.g. @ControllerAdvice) to translate BizException B_CUSTOMER_companyNameConflict into a client-friendly error.
Example fix
// before
throw new BizException(ErrorCode.B_CUSTOMER_companyNameConflict.getErrCode(), "公司名冲突");
// after
if(customerRepository.existsByCompanyName(cmd.getCustomerDTO().getCompanyName())){
throw new BizException(ErrorCode.B_CUSTOMER_companyNameConflict.getErrCode(), "公司名冲突");
} Defensive patterns
Strategy: try-catch
Validate before calling
if ("ConflictCompanyName".equals(cmd.getCustomerDTO().getCompanyName())) {
return Response.buildFailure(ErrorCode.B_CUSTOMER_companyNameConflict.getErrCode(), "公司名冲突");
} Try / catch
@ExceptionHandler(BizException.class)
public Response handleBiz(BizException e) {
if (ErrorCode.B_CUSTOMER_companyNameConflict.getErrCode().equals(e.getErrCode())) {
return Response.buildFailure(e.getErrCode(), "公司名冲突");
}
return Response.buildFailure(e.getErrCode(), e.getErrMessage());
} Prevention
- Pre-check companyName uniqueness before executing the add command.
- Register a global BizException handler (@ControllerAdvice) in the web layer.
- Swap the sentinel-based check for a database uniqueness validation in production code.
When it happens
Trigger: Executing CustomerAddCmd in the cola-archetype-web generated app where cmd.getCustomerDTO().getCompanyName() equals "ConflictCompanyName".
Common situations: Running the generated demo web app with the sample conflict payload; integration tests asserting the error path; reusing the executor template without replacing the hard-coded check.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- B_CUSTOMER_companyNameConflict
- ${companyName} has already existed, you can not add it
- ${companyName} has already existed, you can not add it
- Component ${targetClz} can not be found in Spring Container
- ${errorCode}
AI-assisted analysis of alibaba/COLA@352e1a8675 (2026-09-08).
Data as JSON: /api/errors/1136169612c9b0ce.
Report an issue: GitHub.