{"record":{"id":"c7615e3eaf85a129","repo":"prestodb/presto","slug":"generic-internal-error-c7615e","errorCode":"GENERIC_INTERNAL_ERROR","errorMessage":"Unknown plan phase ","messagePattern":"Unknown plan phase ","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/sql/planner/ConnectorPlanOptimizerManager.java","lineNumber":61,"sourceCode":"        checkArgument(planOptimizerProviders.putIfAbsent(connectorId, planOptimizerProvider) == null,\n                \"ConnectorPlanOptimizerProvider for connector '%s' is already registered\", connectorId);\n    }\n\n    public void removePlanOptimizerProvider(ConnectorId connectorId)\n    {\n        requireNonNull(connectorId, \"connectorId is null\");\n        planOptimizerProviders.remove(connectorId);\n    }\n\n    public Map<ConnectorId, Set<ConnectorPlanOptimizer>> getOptimizers(PlanPhase phase)\n    {\n        switch (phase) {\n            case LOGICAL:\n                return ImmutableMap.copyOf(transformValues(planOptimizerProviders, ConnectorPlanOptimizerProvider::getLogicalPlanOptimizers));\n            case PHYSICAL:\n                return ImmutableMap.copyOf(transformValues(planOptimizerProviders, ConnectorPlanOptimizerProvider::getPhysicalPlanOptimizers));\n            default:\n                throw new PrestoException(GENERIC_INTERNAL_ERROR, \"Unknown plan phase \" + phase);\n        }\n    }\n\n    public enum PlanPhase\n    {\n        LOGICAL, PHYSICAL\n    }\n}\n","sourceCodeStart":43,"sourceCodeEnd":70,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/sql/planner/ConnectorPlanOptimizerManager.java#L43-L70","documentation":"ConnectorPlanOptimizerManager.getOptimizers maps a PlanPhase (LOGICAL or PHYSICAL) to the registered connector optimizer providers. An unknown phase value cannot occur through the enum's normal use, so the default branch throws GENERIC_INTERNAL_ERROR — hitting it means the enum gained a value not handled in the switch, an internal consistency failure.","triggerScenarios":"Adding a new PlanPhase enum constant without updating getOptimizers' switch; reflective/deserialization code producing a phase outside LOGICAL/PHYSICAL; called from PlanOptimizers during plan optimization setup.","commonSituations":"Custom forks of Presto extending PlanPhase; partial upgrades where compiled classes disagree on enum values (mixed coordinator/worker builds).","solutions":["Update the switch in getOptimizers to handle the new PlanPhase constant","Ensure all cluster nodes run the same build to avoid enum value skew","If not modifying Presto, upgrade to a consistent release and report the trigger to maintainers"],"exampleFix":"// before\nswitch (phase) {\n    case LOGICAL: ...; case PHYSICAL: ...;\n    default: throw new PrestoException(GENERIC_INTERNAL_ERROR, \"Unknown plan phase \" + phase);\n}\n// after\nswitch (phase) {\n    case LOGICAL: ...; case PHYSICAL: ...;\n    case RUNTIME: return ImmutableMap.copyOf(transformValues(planOptimizerProviders, ConnectorPlanOptimizerProvider::getRuntimePlanOptimizers));\n    default: throw new PrestoException(GENERIC_INTERNAL_ERROR, \"Unknown plan phase \" + phase);\n}","handlingStrategy":"type-guard","validationCode":"// Exhaustive handling on your side\nboolean supported = phase == PlanPhase.LOGICAL || phase == PlanPhase.PHYSICAL;\nif (!supported) throw new IllegalArgumentException(\"Unsupported phase: \" + phase);","typeGuard":"boolean isKnownPhase(PlanPhase p) {\n    return p == PlanPhase.LOGICAL || p == PlanPhase.PHYSICAL;\n}","tryCatchPattern":"try { manager.getOptimizers(phase); } catch (PrestoException e) { if (e.getErrorCode().equals(GENERIC_INTERNAL_ERROR.toErrorCode()) && e.getMessage().startsWith(\"Unknown plan phase\")) { useDefaultOptimizers(); } else throw e; }","preventionTips":["Never introduce new PlanPhase constants without updating the switch","Keep all cluster nodes on the same build to avoid enum skew","Prefer iterating known phases explicitly rather than reflective enum lookups"],"tags":["planner","enum","internal-error"],"backgroundTag":"unhandled-enum-case","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"}