{"record":{"id":"02188e2589914df4","repo":"apache/beam","slug":"to-queueurl-or-to-dynamicdestination-is-required","errorCode":null,"errorMessage":"to(queueUrl) or to(dynamicDestination) is required","messagePattern":"to\\(queueUrl\\) or to\\(dynamicDestination\\) is required","errorType":"validation","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/amazon-web-services2/src/main/java/org/apache/beam/sdk/io/aws2/sqs/SqsIO.java","lineNumber":613,"sourceCode":"        this.entryMapper = entryMapper;\n        this.handler =\n            AsyncBatchWriteHandler.byId(\n                spec.concurrentRequests(),\n                spec.batchSize(),\n                spec.clientConfiguration().retry(),\n                Stats.NONE,\n                (queue, records) -> sendMessageBatch(sqs, queue, records),\n                error -> error.code(),\n                record -> record.id(),\n                error -> error.id());\n        this.scheduler =\n            spec.strictTimeouts() ? Executors.newSingleThreadScheduledExecutor() : null;\n        if (spec.queueUrl() != null) {\n          this.batches = new Single();\n        } else if (spec.dynamicDestination() != null) {\n          this.batches = new Dynamic(spec.dynamicDestination());\n        } else {\n          throw new IllegalStateException(\"to(queueUrl) or to(dynamicDestination) is required\");\n        }\n      }\n\n      private static CompletableFuture<List<BatchResultErrorEntry>> sendMessageBatch(\n          SqsAsyncClient sqs, String queue, List<SendMessageBatchRequestEntry> records) {\n        SendMessageBatchRequest request =\n            SendMessageBatchRequest.builder().queueUrl(queue).entries(records).build();\n        return sqs.sendMessageBatch(request).thenApply(resp -> resp.failed());\n      }\n\n      public void startBundle() {\n        handler.reset();\n        if (scheduler != null && spec.strictTimeouts()) {\n          long timeout = spec.batchTimeout().getMillis();\n          long period = timeout / CHECKS_PER_TIMEOUT_PERIOD;\n          expirationCheck =\n              scheduler.scheduleWithFixedDelay(\n                  () -> batches.submitExpired(false), timeout, period, MILLISECONDS);","sourceCodeStart":595,"sourceCodeEnd":631,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/amazon-web-services2/src/main/java/org/apache/beam/sdk/io/aws2/sqs/SqsIO.java#L595-L631","documentation":"SqsIO.WriteBatches' setup validates the write destination: if neither a static queueUrl nor a dynamicDestination is configured it throws IllegalStateException 'to(queueUrl) or to(dynamicDestination) is required'. The Sink cannot determine which SQS queue to send batches to.","triggerScenarios":"Applying SqsIO.writeBatches() to a pipeline without calling .to(queueUrl) or .to(DynamicDestination); calling to() with a null/empty value so spec.queueUrl() and spec.dynamicDestination() are both null.","commonSituations":"Copy-pasted write transforms where the .to() call was dropped; building the sink conditionally and forgetting both branches; refactors moving from static to dynamic destinations without setting the other.","solutions":["Call .to(String queueUrl) with the SQS queue URL on the writeBatches builder","Or call .to(DynamicDestinations) to resolve the queue per record","Validate configuration before submitting the pipeline"],"exampleFix":"// before\nsqsData.apply(SqsIO.writeBatches().withSqsClient(client));\n// after\nsqsData.apply(SqsIO.writeBatches()\n    .withSqsClient(client)\n    .to(\"https://sqs.us-east-1.amazonaws.com/123456789012/my-queue\"));","handlingStrategy":"validation","validationCode":"SqsIO.Write<String> w = SqsIO.writeBatches().withSqsClient(client); if (w == null) throw new IllegalArgumentException(\"must call to(queueUrl) or to(dynamicDestination)\");","typeGuard":null,"tryCatchPattern":"try { data.apply(SqsIO.writeBatches().withSqsClient(client)); } catch (IllegalStateException e) { /* add required .to(...) and resubmit */ }","preventionTips":["Always chain .to(...) on writeBatches before applying","Add pipeline configuration validation before job submission","When switching between static/dynamic destinations, update exactly one .to() call"],"tags":["java","sqs","configuration"],"backgroundTag":"missing-required-option","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T21:17:11.552Z"}