alibaba/COLA · warning · BizException
${companyName} has already existed, you can not add it
Error message
${companyName} has already existed, you can not add it What it means
Domain-level conflict check in the web archetype's Customer entity: checkConflict() throws BizException (message includes the company name) when companyName equals "ConflictCompanyName". It represents the duplicate-company-name invariant of the Customer aggregate.
Source
Thrown at cola-archetypes/cola-archetype-web/src/main/resources/archetype-resources/__rootArtifactId__-domain/src/main/java/domain/customer/Customer.java:37
private String companyName;
private SourceType sourceType;
private CompanyType companyType;
public Customer() {
}
public boolean isBigCompany() {
return registeredCapital > 10000000; //注册资金大于1000万的是大企业
}
public boolean isSME() {
return registeredCapital > 10000 && registeredCapital < 1000000; //注册资金大于10万小于100万的为中小企业
}
public void checkConflict(){
//Per different biz, the check policy could be different, if so, use ExtensionPoint
if("ConflictCompanyName".equals(this.companyName)){
throw new BizException(this.companyName+" has already existed, you can not add it");
}
}
}
View on GitHub (pinned to 352e1a8675)
Solutions
- Change the companyName value in the request.
- Implement the real conflict policy via repository lookup or ExtensionPoint instead of the literal string comparison.
- Catch BizException in the executor layer and return a structured error response.
Example fix
// before
if("ConflictCompanyName".equals(this.companyName)){
throw new BizException(this.companyName+" has already existed, you can not add it");
}
// after
if(customerRepository.existsByCompanyName(this.companyName)){
throw new BizException(this.companyName+" has already existed, you can not add it");
} Defensive patterns
Strategy: validation
Validate before calling
if ("ConflictCompanyName".equals(customer.getCompanyName())) {
return Response.buildFailure("CUSTOMER_CONFLICT", customer.getCompanyName() + " has already existed");
}
customer.checkConflict(); Try / catch
try {
customer.checkConflict();
} catch (BizException e) {
return Response.buildFailure(ErrorCode.B_CUSTOMER_companyNameConflict.getErrCode(), e.getMessage());
} Prevention
- Perform uniqueness validation in the executor before invoking the domain entity.
- Replace the hard-coded string with a repository or ExtensionPoint based conflict policy.
- Keep conflict messaging user-facing (avoid leaking sentinel values) by catching BizException centrally.
When it happens
Trigger: Calling customer.checkConflict() during customer creation when this.companyName is "ConflictCompanyName".
Common situations: Demo payloads in the generated web app; tests exercising the conflict branch; template code left in place instead of a real per-business conflict policy.
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
- ${companyName} has already existed, you can not add it
- B_CUSTOMER_companyNameConflict
- B_CUSTOMER_companyNameConflict
- 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/f82e3020cb0f145b.
Report an issue: GitHub.