alibaba/COLA · warning · BizException

B_CUSTOMER_companyNameConflict

B_CUSTOMER_companyNameConflict

Error message

公司名冲突

What it means

CustomerAddCmdExe.execute rejects a customer creation request whose company name equals the sentinel value "ConflictCompanyName", throwing a BizException with error code B_CUSTOMER_companyNameConflict and Chinese message "公司名冲突" (company name conflict). It is the sample duplicate/uniqueness guard of the COLA service archetype.

Source

Thrown at cola-archetypes/cola-archetype-service/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, "公司名冲突");
        }
        return Response.buildSuccess();
    }

}

View on GitHub (pinned to 352e1a8675)

Solutions

  1. Change the submitted companyName to a non-conflicting value.
  2. Replace the hard-coded "ConflictCompanyName" check with a real uniqueness check against persistence (query existing customer by name) before insert.
  3. Handle BizException with code B_CUSTOMER_companyNameConflict in the web layer and return a user-friendly response.

Example fix

// before
if(cmd.getCustomerDTO().getCompanyName().equals("ConflictCompanyName")){
    throw new BizException(ErrorCode.B_CUSTOMER_companyNameConflict, "公司名冲突");
}
// after
if(customerRepository.existsByCompanyName(cmd.getCustomerDTO().getCompanyName())){
    throw new BizException(ErrorCode.B_CUSTOMER_companyNameConflict, "公司名冲突");
}
Defensive patterns

Strategy: validation

Validate before calling

if ("ConflictCompanyName".equals(cmd.getCustomerDTO().getCompanyName())) {
    return Response.buildFailure(ErrorCode.B_CUSTOMER_companyNameConflict.getErrCode(), "公司名冲突");
}

Try / catch

try {
    return customerAddCmdExe.execute(cmd);
} catch (BizException e) {
    if (ErrorCode.B_CUSTOMER_companyNameConflict.getErrCode().equals(e.getErrCode())) {
        return Response.buildFailure(e.getErrCode(), "公司名冲突,请更换公司名");
    }
    throw e;
}

Prevention

When it happens

Trigger: Executing CustomerAddCmd where cmd.getCustomerDTO().getCompanyName() equals "ConflictCompanyName" — i.e. a demo/test payload that trips the sample conflict check in the command executor.

Common situations: Demo clients or integration tests posting the literal "ConflictCompanyName"; developers reusing the archetype executor and forgetting to replace the hard-coded conflict check with real database uniqueness validation.

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/38d93dc5f3409886. Report an issue: GitHub.