{"record":{"id":"f7720878f251b69a","repo":"apache/seatunnel","slug":"field-type-mapping-error","errorCode":"FIELD_TYPE_MAPPING_ERROR","errorMessage":"FIELD_TYPE_MAPPING_ERROR.getDescription()","messagePattern":"FIELD_TYPE_MAPPING_ERROR\\.getDescription\\(\\)","errorType":"error_code","errorClass":"TypesenseConnectorException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-typesense/src/main/java/org/apache/seatunnel/connectors/seatunnel/typesense/client/TypesenseClient.java","lineNumber":186,"sourceCode":"            throw new TypesenseConnectorException(\n                    QUERY_COLLECTION_LIST_ERROR, QUERY_COLLECTION_LIST_ERROR.getDescription());\n        }\n    }\n\n    public Map<String, String> getField(String collection) {\n        if (collectionExists(collection)) {\n            Map<String, String> fieldMap = new HashMap<>();\n            try {\n                CollectionResponse collectionResponse = tsClient.collections(collection).retrieve();\n                List<Field> fields = collectionResponse.getFields();\n                for (Field field : fields) {\n                    String fieldName = field.getName();\n                    String type = field.getType();\n                    fieldMap.put(fieldName, type);\n                }\n            } catch (Exception e) {\n                log.error(FIELD_TYPE_MAPPING_ERROR.getDescription());\n                throw new TypesenseConnectorException(\n                        FIELD_TYPE_MAPPING_ERROR, FIELD_TYPE_MAPPING_ERROR.getDescription());\n            }\n            return fieldMap;\n        } else {\n            return null;\n        }\n    }\n\n    public Map<String, BasicTypeDefine<TypesenseType>> getFieldTypeMapping(String collection) {\n        Map<String, BasicTypeDefine<TypesenseType>> allTypesenseSearchFieldTypeInfoMap =\n                new HashMap<>();\n        try {\n            CollectionResponse collectionResponse = tsClient.collections(collection).retrieve();\n            List<Field> fields = collectionResponse.getFields();\n            for (Field field : fields) {\n                String fieldName = field.getName();\n                String type = field.getType();\n                BasicTypeDefine.BasicTypeDefineBuilder<TypesenseType> typeDefine =","sourceCodeStart":168,"sourceCodeEnd":204,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-typesense/src/main/java/org/apache/seatunnel/connectors/seatunnel/typesense/client/TypesenseClient.java#L168-L204","documentation":"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.","triggerScenarios":"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.","commonSituations":"Querying fields of a collection that was dropped mid-job; collection created externally with nested fields the parser doesn't expect; auth/network failures.","solutions":["Check collectionExists(collection) first — a non-existent collection returns null from getField rather than throwing","Verify the collection schema is valid Typesense field definitions with a supported type string","Ensure API credentials and connectivity are valid for the /collections/{name} endpoint","Chain the caught exception when rethrowing to expose the parse/IO root cause"],"exampleFix":"// before\n} catch (Exception e) {\n    log.error(FIELD_TYPE_MAPPING_ERROR.getDescription());\n    throw new TypesenseConnectorException(FIELD_TYPE_MAPPING_ERROR, FIELD_TYPE_MAPPING_ERROR.getDescription());\n}\n// after\n} catch (Exception e) {\n    log.error(FIELD_TYPE_MAPPING_ERROR.getDescription(), e);\n    throw new TypesenseConnectorException(FIELD_TYPE_MAPPING_ERROR, FIELD_TYPE_MAPPING_ERROR.getDescription(), e);\n}","handlingStrategy":"validation","validationCode":"if (client.collectionExists(collection)) {\n    Map<String, String> fields = client.getField(collection); // non-null here\n} else {\n    // handle missing collection instead of relying on null\n}","typeGuard":"boolean hasFields(Map<String, String> m) { return m != null && !m.isEmpty(); }","tryCatchPattern":"try {\n    fieldMap = client.getField(collection);\n} catch (TypesenseConnectorException e) {\n    // schema fetch failed; fall back to explicit schema in config\n}","preventionTips":["Always null-check getField's return value — missing collections return null, not throw","Ensure the collection schema only uses Typesense-supported field types","Confirm credentials/network before schema reads"],"tags":["typesense","field-mapping","schema"],"backgroundTag":"unexpected-response-shape","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}