{"record":{"id":"265fe20fa6c13739","repo":"prestodb/presto","slug":"invalid-function-argument-265fe2","errorCode":"INVALID_FUNCTION_ARGUMENT","errorMessage":"e.getMessage()","messagePattern":"e\\.getMessage\\(\\)","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-geospatial-toolkit/src/main/java/com/facebook/presto/geospatial/serde/EsriGeometrySerde.java","lineNumber":179,"sourceCode":"    {\n        requireNonNull(shape, \"shape is null\");\n        BasicSliceInput input = shape.getInput();\n        verify(input.available() > 0);\n        return GeometrySerializationType.getForCode(input.readByte());\n    }\n\n    public static OGCGeometry deserialize(Slice shape)\n    {\n        requireNonNull(shape, \"shape is null\");\n        BasicSliceInput input = shape.getInput();\n        verify(input.available() > 0);\n        int length = input.available() - 1;\n        GeometrySerializationType type = GeometrySerializationType.getForCode(input.readByte());\n        try {\n            return readGeometry(input, shape, type, length);\n        }\n        catch (GeometryException e) {\n            throw new PrestoException(INVALID_FUNCTION_ARGUMENT, e.getMessage(), e);\n        }\n    }\n\n    private static OGCGeometry readGeometry(BasicSliceInput input, Slice inputSlice, GeometrySerializationType type, int length)\n    {\n        switch (type) {\n            case POINT:\n                return readPoint(input);\n            case MULTI_POINT:\n            case LINE_STRING:\n            case MULTI_LINE_STRING:\n            case POLYGON:\n            case MULTI_POLYGON:\n                return readSimpleGeometry(input, inputSlice, type, length);\n            case GEOMETRY_COLLECTION:\n                return readGeometryCollection(input, inputSlice);\n            case ENVELOPE:\n                return createFromEsriGeometry(readEnvelope(input), false);","sourceCodeStart":161,"sourceCodeEnd":197,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-geospatial-toolkit/src/main/java/com/facebook/presto/geospatial/serde/EsriGeometrySerde.java#L161-L197","documentation":"EsriGeometrySerde.deserialize wraps GeometryException raised while decoding a serialized geometry blob and rethrows it as INVALID_FUNCTION_ARGUMENT with the original message. It means the binary value in a geometry-typed column/argument could not be deserialized to an OGCGeometry.","triggerScenarios":"Reading a geometry column whose bytes violate the Esri serialization format (bad type code byte, truncated slice, wrong length), or manually inserting/passing invalid binary as a geometry.","commonSituations":"ETL jobs writing geometries with a different serialization (e.g. JTS-flavored) into Esri-decoded columns, truncated values from external storage, corrupted WKB from upstream tools.","solutions":["Re-serialize the geometry through Presto itself: ST_AsBinary/ST_GeometryFromText round-trip to produce a valid blob.","Validate the source data's encoding matches the expected Presto geometry serialization.","Locate and quarantine the corrupt row(s) by scanning with ST_IsEmpty/ST_GeometryType.","Fix the upstream producer to emit Presto-compatible geometry varbinary."],"exampleFix":"// before\nINSERT INTO geo_table SELECT raw_bytes FROM staged_data; -- arbitrary varbinary\n// after\nINSERT INTO geo_table SELECT ST_AsBinary(ST_GeometryFromText(wkt)) FROM staged_data; -- valid geometry blob","handlingStrategy":"validation","validationCode":"-- pre-check that geometry values decode\nSELECT * FROM t WHERE TRY(ST_GeometryFromText(ST_AsText(geom))) IS NULL; -- find un-decodable rows before real query","typeGuard":"boolean isDecodableGeometry(byte[] blob) { try { EsriGeometrySerde.deserialize(wrap(blob)); return true; } catch (Exception e) { return false; } }","tryCatchPattern":"try { rows = query(); } catch (PrestoException e) { if (\"INVALID_FUNCTION_ARGUMENT\".equals(e.getErrorCode().getName())) { quarantineBadRows(); return safeQuery(); } throw e; }","preventionTips":["Write geometries only via ST_AsBinary/ST_AsText from Presto.","Validate serialized blobs at ingestion.","Avoid mixing serialization formats across Presto versions.","Checksum/verify geometry data copied between systems."],"tags":["geospatial","serialization","corrupt-data"],"backgroundTag":"geometry-deserialization-failed","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}