{"record":{"id":"5ee62bff22a3838b","repo":"apache/beam","slug":"error-search-fhir-resources-writing-to-dead-letter-queue","errorCode":null,"errorMessage":"Error search FHIR resources writing to Dead Letter Queue.","messagePattern":"Error search FHIR resources writing to Dead Letter Queue\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/healthcare/FhirIO.java","lineNumber":2003,"sourceCode":"      }\n\n      /**\n       * Process element.\n       *\n       * @param context the context\n       */\n      @ProcessElement\n      public void processElement(ProcessContext context) {\n        FhirSearchParameter<T> fhirSearchParameters = context.element();\n        try {\n          context.output(\n              KV.of(\n                  fhirSearchParameters.getKey(),\n                  searchResources(\n                      fhirSearchParameters.getResourceType(), fhirSearchParameters.getQueries())));\n        } catch (IllegalArgumentException | NoSuchElementException e) {\n          searchResourcesErrorCount.inc();\n          log.warn(\"Error search FHIR resources writing to Dead Letter Queue.\", e);\n          context.output(\n              FhirIO.Search.DEAD_LETTER, HealthcareIOError.of(fhirSearchParameters.toString(), e));\n        }\n      }\n\n      private JsonArray searchResources(String resourceType, @Nullable Map<String, T> parameters)\n          throws NoSuchElementException {\n        long start = Instant.now().toEpochMilli();\n\n        HashMap<String, Object> parameterObjects = new HashMap<>();\n        if (parameters != null) {\n          parameters.forEach(parameterObjects::put);\n        }\n        FhirResourcePagesIterator iter =\n            FhirResourcePagesIterator.ofSearch(\n                client, fhirStore.toString(), resourceType, parameterObjects);\n        JsonArray result = new JsonArray();\n        while (iter.hasNext()) {","sourceCodeStart":1985,"sourceCodeEnd":2021,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/healthcare/FhirIO.java#L1985-L2021","documentation":"FhirIO.Search's processElement executes a FHIR search per (store, parameters) pair. If the search parameters are invalid (IllegalArgumentException) or no results exist where the code requires one (NoSuchElementException), the searchResourcesErrorCount metric is incremented, this warning logged, and the input parameters are emitted to FhirIO.Search.DEAD_LETTER as a HealthcareIOError so the pipeline keeps running.","triggerScenarios":"Passing an invalid resource type or malformed query parameter map to FhirIO.search(); a search returning an empty bundle where the code unconditionally reads the first entry (NoSuchElementException); bad fhirStore strings.","commonSituations":"Typo'd search parameters (e.g. unsupported search key for the resource type); searching a resource type not configured in the store; queries with invalid date/value syntax; pagination edge cases producing empty pages.","solutions":["Read the DEAD_LETTER HealthcareIOError to see which parameters and exception caused the failure.","Validate resource type names against the FHIR spec and confirm search parameter keys are supported for that type.","Handle empty result sets explicitly in your parameters/queries before calling search.","Check fhirStore path format and store configuration in the Healthcare API."],"exampleFix":"// before\ninput.apply(FhirIO.search())  // with parameters map containing unsupported key\n// after\n// validate parameters first\nMap<String, DiscreteValue> validated = validateSearchKeys(resourceType, params);\nvalidated.apply(FhirIO.search());","handlingStrategy":"validation","validationCode":"// Java: sanity-check search parameters before FhirIO.search()\nif (resourceType == null || resourceType.isBlank() || !FHIR_RESOURCE_TYPES.contains(resourceType)) {\n  throw new IllegalArgumentException(\"Unsupported FHIR resource type: \" + resourceType);\n}\nfor (String key : parameters.keySet()) {\n  if (!SUPPORTED_SEARCH_KEYS.getOrDefault(resourceType, Set.of()).contains(key)) {\n    throw new IllegalArgumentException(\"Unsupported search key \" + key + \" for \" + resourceType);\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Consume FhirIO.Search.DEAD_LETTER and alert on it.","Validate resource types and search keys against your store's FHIR version.","Handle empty search results explicitly before downstream entry access."],"tags":["gcp-healthcare","fhir","search","dead-letter"],"backgroundTag":"invalid-query-parameter","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}