{"record":{"id":"c3a86e17628984fe","repo":"prestodb/presto","slug":"thrift-service-invalid-response","errorCode":"THRIFT_SERVICE_INVALID_RESPONSE","errorMessage":"Requested and actual table names are different","messagePattern":"Requested and actual table names are different","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-thrift-connector/src/main/java/com/facebook/presto/connector/thrift/ThriftMetadata.java","lineNumber":207,"sourceCode":"        if (!table.isPresent()) {\n            throw new TableNotFoundException(schemaTableName);\n        }\n        else {\n            return table.get();\n        }\n    }\n\n    // this method makes actual thrift request and should be called only by cache load method\n    private Optional<ThriftTableMetadata> getTableMetadataInternal(SchemaTableName schemaTableName)\n    {\n        requireNonNull(schemaTableName, \"schemaTableName is null\");\n        PrestoThriftNullableTableMetadata thriftTableMetadata = getTableMetadata(schemaTableName);\n        if (thriftTableMetadata.getTableMetadata() == null) {\n            return Optional.empty();\n        }\n        ThriftTableMetadata tableMetadata = new ThriftTableMetadata(thriftTableMetadata.getTableMetadata(), typeManager);\n        if (!Objects.equals(schemaTableName, tableMetadata.getSchemaTableName())) {\n            throw new PrestoException(THRIFT_SERVICE_INVALID_RESPONSE, \"Requested and actual table names are different\");\n        }\n        return Optional.of(tableMetadata);\n    }\n\n    private PrestoThriftNullableTableMetadata getTableMetadata(SchemaTableName schemaTableName)\n    {\n        // treat invalid names as not found\n        PrestoThriftSchemaTableName name;\n        try {\n            name = new PrestoThriftSchemaTableName(schemaTableName);\n        }\n        catch (IllegalArgumentException e) {\n            return new PrestoThriftNullableTableMetadata(null);\n        }\n\n        try {\n            return client.get().getTableMetadata(name);\n        }","sourceCodeStart":189,"sourceCodeEnd":225,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-thrift-connector/src/main/java/com/facebook/presto/connector/thrift/ThriftMetadata.java#L189-L225","documentation":"ThriftMetadata.getTableMetadataInternal fetches table metadata from the external Thrift service and cross-checks that the returned table's schema/name matches what was requested. A mismatch means the service responded with metadata for a different table, treated as an invalid service response.","triggerScenarios":"Thrift connector server returns PrestoThriftTableMetadata whose schemaTableName differs from the requested SchemaTableName (lookup is typically case-sensitive).","commonSituations":"Misbehaving or buggy Thrift service returning default/empty names, case normalization differences between the service and Presto, or stale caching in the external service.","solutions":["Fix the Thrift service to echo back the exact requested schema/table name","Match identifier casing between client request and service response","Upgrade/restart the external Thrift connector service if it has a known bug","Verify the service implementation handles unknown tables by returning null rather than partial metadata"],"exampleFix":"// before (thrift service)\nreturn new PrestoThriftTableMetadata(\"\", tableName, columns);\n// after\nreturn new PrestoThriftTableMetadata(requestedSchema, requestedTable, columns);","handlingStrategy":"try-catch","validationCode":"// verify the thrift service echoes names: assert response.getTableMetadata().getSchemaName().equals(requestedSchema) && response.getTableMetadata().getTableName().equals(requestedTable)","typeGuard":null,"tryCatchPattern":"try { return thriftMetadata.getTableHandle(name); } catch (PrestoException e) { if (THRIFT_SERVICE_INVALID_RESPONSE == e.getErrorCode().getCode()) { refreshServiceClient(); return retryLookup(name); } throw e; }","preventionTips":["Keep identifier casing consistent between service and Presto","Test thrift service responses against requested names in CI","Handle unknown tables by returning null metadata, never partial records"],"tags":["thrift-connector","invalid-response","metadata","protocol"],"backgroundTag":"invalid-service-response","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"}