apache/seatunnel · error · TypesenseConnectorException

FIELD_TYPE_MAPPING_ERROR

FIELD_TYPE_MAPPING_ERROR

Error message

FIELD_TYPE_MAPPING_ERROR.getDescription()

What it means

TypesenseClient.getField() reads a collection's field schema and maps it into a field-name→type map; any exception during that mapping/parse is rethrown as TypesenseConnectorException with FIELD_TYPE_MAPPING_ERROR. Returns null instead when the collection does not exist.

Source

Thrown at seatunnel-connectors-v2/connector-typesense/src/main/java/org/apache/seatunnel/connectors/seatunnel/typesense/client/TypesenseClient.java:186

            throw new TypesenseConnectorException(
                    QUERY_COLLECTION_LIST_ERROR, QUERY_COLLECTION_LIST_ERROR.getDescription());
        }
    }

    public Map<String, String> getField(String collection) {
        if (collectionExists(collection)) {
            Map<String, String> fieldMap = new HashMap<>();
            try {
                CollectionResponse collectionResponse = tsClient.collections(collection).retrieve();
                List<Field> fields = collectionResponse.getFields();
                for (Field field : fields) {
                    String fieldName = field.getName();
                    String type = field.getType();
                    fieldMap.put(fieldName, type);
                }
            } catch (Exception e) {
                log.error(FIELD_TYPE_MAPPING_ERROR.getDescription());
                throw new TypesenseConnectorException(
                        FIELD_TYPE_MAPPING_ERROR, FIELD_TYPE_MAPPING_ERROR.getDescription());
            }
            return fieldMap;
        } else {
            return null;
        }
    }

    public Map<String, BasicTypeDefine<TypesenseType>> getFieldTypeMapping(String collection) {
        Map<String, BasicTypeDefine<TypesenseType>> allTypesenseSearchFieldTypeInfoMap =
                new HashMap<>();
        try {
            CollectionResponse collectionResponse = tsClient.collections(collection).retrieve();
            List<Field> fields = collectionResponse.getFields();
            for (Field field : fields) {
                String fieldName = field.getName();
                String type = field.getType();
                BasicTypeDefine.BasicTypeDefineBuilder<TypesenseType> typeDefine =

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Check collectionExists(collection) first — a non-existent collection returns null from getField rather than throwing
  2. Verify the collection schema is valid Typesense field definitions with a supported type string
  3. Ensure API credentials and connectivity are valid for the /collections/{name} endpoint
  4. Chain the caught exception when rethrowing to expose the parse/IO root cause

Example fix

// before
} catch (Exception e) {
    log.error(FIELD_TYPE_MAPPING_ERROR.getDescription());
    throw new TypesenseConnectorException(FIELD_TYPE_MAPPING_ERROR, FIELD_TYPE_MAPPING_ERROR.getDescription());
}
// after
} catch (Exception e) {
    log.error(FIELD_TYPE_MAPPING_ERROR.getDescription(), e);
    throw new TypesenseConnectorException(FIELD_TYPE_MAPPING_ERROR, FIELD_TYPE_MAPPING_ERROR.getDescription(), e);
}
Defensive patterns

Strategy: validation

Validate before calling

if (client.collectionExists(collection)) {
    Map<String, String> fields = client.getField(collection); // non-null here
} else {
    // handle missing collection instead of relying on null
}

Type guard

boolean hasFields(Map<String, String> m) { return m != null && !m.isEmpty(); }

Try / catch

try {
    fieldMap = client.getField(collection);
} catch (TypesenseConnectorException e) {
    // schema fetch failed; fall back to explicit schema in config
}

Prevention

When it happens

Trigger: Calling getField(collection) for a collection whose fields cannot be fetched or parsed — collection missing (results in null), server error during /collections/{name} retrieval, or unexpected field descriptors.

Common situations: Querying fields of a collection that was dropped mid-job; collection created externally with nested fields the parser doesn't expect; auth/network failures.

Related errors


AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10). Data as JSON: /api/errors/f7720878f251b69a. Report an issue: GitHub.