Skip to main content

Error Code Reference

This page catalogs common error codes and error types encountered when developing and running integrations with WSO2 Integrator. Errors are organized by category to help you quickly identify the source and resolution.

HTTP Errors

These errors originate from ballerina/http client and server operations.

Error TypeHTTP StatusCommon CausesResolution
http:ClientRequestError4xxMalformed request sent by the HTTP clientVerify the request URL, headers, and payload format. Check that path parameters and query strings are properly encoded.
http:BadRequest400Invalid request payload or missing required parametersValidate the request body against the expected schema. Ensure all required fields are present.
http:Unauthorized401Missing or invalid authentication credentialsVerify that the Authorization header is present and contains a valid token or credential. Check token expiry.
http:Forbidden403Authenticated but insufficient permissionsConfirm the authenticated user or service account has the required roles or scopes.
http:NotFound404Resource does not exist at the requested URLCheck the URL path, verify the resource exists, and confirm the service is deployed.
http:MethodNotAllowed405HTTP method not supported for the endpointVerify the HTTP method (GET, POST, PUT, etc.) matches the resource function definition.
http:PayloadTooLarge413Request body exceeds the configured size limitIncrease the maxEntityBodySize in the listener configuration or reduce the payload size.
http:InternalServerError500Unhandled error in the service logicCheck application logs for the root cause. Ensure all error values are properly handled with check or do/on fail.
http:ServiceUnavailable503Backend service is down or circuit breaker is openVerify the backend service is running. Check circuit breaker configuration and retry settings.
http:ClientConnectorError--Unable to establish a connection to the remote hostVerify the target URL is correct and reachable. Check network connectivity, DNS resolution, and firewall rules.
http:SslError--TLS/SSL handshake failureVerify certificate validity, ensure the truststore contains the server's CA certificate, and confirm TLS version compatibility.
http:IdleTimeoutError--Connection timed out waiting for a responseIncrease the timeout setting on the HTTP client or investigate why the backend is slow.
http:ApplicationResponseErrorvariesNon-2xx HTTP response from backendCheck detail().statusCode and handle specific status codes accordingly.
http:ClientAuthError--Authentication failure at client levelRefresh credentials, check OAuth config, or verify token endpoint availability.
http:CircuitBreakerError--Circuit breaker is in open stateWait for the reset period. Check backend health and circuit breaker thresholds.
http:NoContentError--No response body returnedCheck that the endpoint returns the expected content type and body.

Database (SQL) Errors

These errors originate from ballerina/sql and database connector packages (ballerinax/mysql, ballerinax/postgresql, etc.).

Error TypeCommon CausesResolution
sql:ErrorBase type for all SQL errorsCheck the error message for specifics. Inspect detail() for SQL state and vendor code.
sql:DatabaseErrorSQL syntax error, constraint violation, or database-level failureCheck the query syntax and data constraints. Verify the database schema matches expectations.
sql:ApplicationErrorType mismatch during result mapping or serializationEnsure the Ballerina record type matches the database column types and names.
sql:NoRowsErrorqueryRow returned no resultsHandle the empty result case. Use queryRow with a union return type (e.g., Order?) or catch this error explicitly.
sql:DuplicateKeyErrorINSERT violated a unique constraintCheck for existing records before inserting, or use ON DUPLICATE KEY UPDATE / ON CONFLICT.
sql:ConnectionErrorCannot connect to the database serverVerify the host, port, credentials, and database name. Ensure the database server is running and accessible.
sql:PoolErrorConnection pool exhaustedIncrease maxOpenConnections in the client configuration, or investigate connection leaks (unclosed clients).
sql:BatchExecuteErrorOne or more statements in a batch operation failedInspect the detail() record for per-statement error information.

Connector Errors

These errors occur when communicating with external systems through Ballerina connectors.

Error TypeCommon CausesResolution
kafka:ErrorBroker unreachable, topic not found, serialization failureVerify broker addresses, topic existence, and serializer/deserializer configuration. Check broker logs.
rabbitmq:ErrorConnection refused, queue or exchange not foundVerify RabbitMQ connection parameters (host, port, credentials). Ensure the exchange and queue exist.
email:ErrorSMTP authentication failure, invalid recipientVerify mail server settings, credentials, and port. Ensure TLS is configured correctly for the mail server.
ftp:ErrorFTP/SFTP authentication failure, path not foundVerify host, port, credentials, and file paths. Check server permissions for the target directory.
grpc:ErrorgRPC call failure, deadline exceeded, unavailableVerify the service URL, proto definition compatibility, and TLS configuration.
graphql:ErrorQuery syntax error, field name mismatchCheck the query syntax, field names, and variable types against the schema.
websocket:ErrorConnection upgrade failure, message send failureVerify the WebSocket URL and ensure the server supports WebSocket protocol upgrade.
mqtt:ErrorBroker connection failure, subscription errorVerify broker URL, client ID uniqueness, and topic filter syntax.

Build and Compilation Errors

These errors appear during bal build or bal run.

Error PatternCommon CausesResolution
error: incompatible typesAssigning a value to a variable of an incompatible typeCheck the type of the expression and the target variable. Use type conversion or type guard.
error: unreachable codeCode after a return, panic, or guaranteed branchRemove or restructure the unreachable code.
error: undefined moduleImporting a module that is not in dependenciesRun bal build to auto-resolve, or add the dependency to Ballerina.toml.
error: undefined symbolUsing a variable or function that is not declaredCheck spelling, import the correct module, or declare the symbol.
error: missing required configurableA configurable variable with no default (= ?) is not providedSupply the value in Config.toml, via environment variables, or as a command-line argument.
error: cyclic dependencyTwo or more modules depend on each otherRefactor to break the circular dependency. Extract shared types into a separate module.
error: ambiguous typeThe compiler cannot infer the type in a given contextAdd an explicit type annotation to resolve the ambiguity.
error: listener startup failedPort already in use or TLS configuration errorCheck port availability and verify certificate file paths.
PANIC: ...Unrecoverable runtime errorCheck the panic message. Usually caused by configuration or initialization failure.

Configuration Errors

These errors occur when providing values to configurable variables.

Error PatternCommon CausesResolution
configurable variable not foundTOML key does not match any configurable declarationCheck the variable name and module qualifier in Config.toml.
invalid TOML valueTOML value type does not match the Ballerina typeEnsure the TOML value matches the expected type (e.g., integer literal for an int configurable).
missing required configurableA required configurable variable (= ?) has no valueProvide the value through Config.toml, BAL_CONFIG_DATA, BAL_CONFIG_VAR_*, or -C flag.
invalid config file pathBAL_CONFIG_FILES points to a nonexistent fileVerify the file path exists and is readable.

Handling Errors in Code

Use Ballerina's do/on fail pattern to handle specific error types differently:

// Pattern: Handle specific errors differently
function callApi() returns json|error {
do {
return check apiClient->get("/data");
} on fail http:IdleTimeoutError e {
log:printWarn("Timeout, retrying...");
return check apiClient->get("/data");
} on fail http:ApplicationResponseError e {
int status = e.detail().statusCode;
if status == 404 {
return {message: "Not found"};
}
return error("API error: HTTP " + status.toString());
} on fail error e {
log:printError("Unexpected error", 'error = e);
return error("Service unavailable");
}
}

What's Next