{"record":{"id":"671521676bf0a1f7","repo":"apache/flink","slug":"no-cluster-id-was-specified-please-specify-a-clus","errorCode":null,"errorMessage":"No cluster id was specified. Please specify a cluster to which you would like to connect.","messagePattern":"No cluster id was specified\\. Please specify a cluster to which you would like to connect\\.","errorType":"exception","errorClass":"FlinkException","httpStatus":null,"severity":"error","filePath":"flink-clients/src/main/java/org/apache/flink/client/cli/CliFrontend.java","lineNumber":1199,"sourceCode":"     * @throws FlinkException if something goes wrong\n     */\n    private <ClusterID> void runClusterAction(\n            CustomCommandLine activeCommandLine,\n            CommandLine commandLine,\n            ClusterAction<ClusterID> clusterAction)\n            throws FlinkException {\n        final Configuration effectiveConfiguration =\n                getEffectiveConfiguration(activeCommandLine, commandLine);\n        LOG.debug(\n                \"Effective configuration after Flink conf, and custom commandline: {}\",\n                effectiveConfiguration);\n\n        final ClusterClientFactory<ClusterID> clusterClientFactory =\n                clusterClientServiceLoader.getClusterClientFactory(effectiveConfiguration);\n\n        final ClusterID clusterId = clusterClientFactory.getClusterId(effectiveConfiguration);\n        if (clusterId == null) {\n            throw new FlinkException(\n                    \"No cluster id was specified. Please specify a cluster to which you would like to connect.\");\n        }\n\n        try (final ClusterDescriptor<ClusterID> clusterDescriptor =\n                clusterClientFactory.createClusterDescriptor(effectiveConfiguration)) {\n            try (final ClusterClient<ClusterID> clusterClient =\n                    clusterDescriptor.retrieve(clusterId).getClusterClient()) {\n                clusterAction.runAction(clusterClient, effectiveConfiguration);\n            }\n        }\n    }\n\n    /**\n     * Internal interface to encapsulate cluster actions which are executed via the {@link\n     * ClusterClient}.\n     *\n     * @param <ClusterID> type of the cluster id\n     */","sourceCodeStart":1181,"sourceCodeEnd":1217,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-clients/src/main/java/org/apache/flink/client/cli/CliFrontend.java#L1181-L1217","documentation":"Thrown by CliFrontend.runClusterAction when the selected ClusterClientFactory returns a null clusterId from the effective configuration. This means Flink resolved a deployment target type (the factory was found) but the configuration did not contain a concrete, already-running cluster identifier to connect to. It occurs for cluster-action commands — cancel, stop, savepoint, list, checkpoint — that operate on an existing cluster rather than deploying a new one.","triggerScenarios":"Running `flink cancel <jobId>`, `flink stop`, or `flink savepoint` without specifying the cluster address (-m / --target) or the deployment-specific cluster identifier (e.g., -yid for YARN application id, -Dexecution.target for Kubernetes session id). The active custom command line resolves a factory but getClusterId returns null because no connection target is configured.","commonSituations":"Using the CLI against a YARN cluster but forgetting -yid <appId>; targeting a Kubernetes cluster without -Dkubernetes.cluster-id; pointing at a remote standalone cluster without -m <host>:<port>; misconfigured flink-conf.yaml where jobmanager.rpc.address is unset and no -m override is given.","solutions":["Add the -m/--target flag with the JobManager address, e.g. `flink cancel -m <host>:<port> <jobId>`","For YARN, include -yid <applicationId> so getClusterId can extract the running YARN application","For Kubernetes, set -Dkubernetes.cluster-id=<id> to target the right session cluster","Verify that the active custom command line (checked in validateAndGetActiveCommandLine) actually parses the connection options you provided"],"exampleFix":"// before\nflink cancel <jobId>\n\n// after\nflink cancel -m my-jm-host:8081 <jobId>\n// or for YARN\nflink cancel -yid application_123456789_0001 <jobId>","handlingStrategy":"validation","validationCode":"// Before calling runClusterAction or any cluster-action CLI command,\n// verify the cluster ID resolves non-null from the factory:\nClusterClientFactory<?> factory = serviceLoader.getClusterClientFactory(config);\nif (factory.getClusterId(config) == null) {\n    throw new IllegalArgumentException(\"No cluster id in configuration. Set -m/--target, -yid, or -Dkubernetes.cluster-id.\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    runClusterAction(activeCommandLine, commandLine, action);\n} catch (FlinkException e) {\n    if (e.getMessage().contains(\"No cluster id\")) {\n        System.err.println(\"Specify the cluster with -m, -yid, or -Dkubernetes.cluster-id\");\n    }\n    throw e;\n}","preventionTips":["Always pass -m/--target with the JobManager address for standalone clusters","For YARN, include -yid with the running YARN application ID","Wrap cluster-action calls and check for null clusterId before proceeding"],"tags":["cli","deployment","cluster-connection","configuration"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}