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

Customer.checkConflict() is a domain method enforcing that a customer's company name does not collide with an existing one; in the archetype it throws BizException when companyName equals the sentinel "ConflictCompanyName". The message embeds the actual conflicting company name.

Source

Thrown at cola-archetypes/cola-archetype-service/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

  1. Use a different companyName value in the request.
  2. Replace the hard-coded string comparison with a real conflict policy (repository existence check or per-biz ExtensionPoint).
  3. Catch BizException from checkConflict() at the executor level and map it to a proper 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())) {
    customer.checkConflict();
} else {
    return Response.buildFailure("CUSTOMER_CONFLICT", customer.getCompanyName() + " has already existed");
}

Try / catch

try {
    customer.checkConflict();
} catch (BizException e) {
    return Response.buildFailure(ErrorCode.B_CUSTOMER_companyNameConflict.getErrCode(), e.getMessage());
}

Prevention

When it happens

Trigger: Calling customer.checkConflict() (typically from a creation use case) when this.customerName/companyName equals "ConflictCompanyName".

Common situations: Demo/test data using the sentinel name; developers copying this domain entity and forgetting to replace the literal with a real duplicate check (e.g. repository lookup or ExtensionPoint 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


AI-assisted analysis of alibaba/COLA@352e1a8675 (2026-09-08). Data as JSON: /api/errors/3b46abbc18a7db55. Report an issue: GitHub.