apache/beam · error
error occurred while performing search for query
Error message
error occurred while performing search for query: [%v]
What it means
searchResourcesFn.ProcessElement executes a FHIR search query via fn.searchResources (which internally pages through SearchQuery results). Any error from the search — transport failure, non-OK API response, or pagination failure — is wrapped with this message including the SearchQuery, emitted to the dead-letter channel, and counted as an error instead of emitting found resources.
Solutions
- Validate the SearchQuery parameters against the FHIR store's supported search parameters (CapabilityStatement)
- Check the wrapped cause in the dead-letter string for the HTTP status code
- Test the equivalent REST call: GET <fhirStore>/fhir/<type>?<params> with the same credentials
- Retry with backoff for transient failures; split large searches into smaller pages/date ranges
- Verify store path and identity; ensure the resource type exists in the store
Example fix
// before
emitDeadLetter(errors.Wrapf(err, "error occurred while performing search for query: [%v]", query).Error())
// after
if isTransient(err) && attempt < maxAttempts { return retrySearch(query, attempt+1) }
emitDeadLetter(errors.Wrapf(err, "error occurred while performing search for query: [%v]", query).Error()) Defensive patterns
Strategy: validation
Validate before calling
// check the search parameter is supported by the store
params := []string{query.Parameter}
supported := fetchSupportedSearchParameters(fhirStoreURL) // from CapabilityStatement
for _, p := range params {
if !contains(supported, p) { return fmt.Errorf("unsupported search param %q", p) }
} Try / catch
// wrap searchResources with bounded retries
result, err := retry(3, backoff, func() ([]string, error) {
return fn.searchResources(ctx, query)
})
if err != nil { emitDeadLetter(...); return } Prevention
- Validate SearchQuery parameters against the store's CapabilityStatement
- Test queries via REST before wiring them into the pipeline
- Page searches with count/date ranges instead of unbounded queries
- Monitor dead-letter output for systemic failures
When it happens
Trigger: executeAndRecordLatency(...searchResources...) returns an error for the given SearchQuery: bad query parameters rejected by the server, network failure, invalid identifier/store path, or errors while fetching subsequent pages of results.
Common situations: Invalid FHIR search parameter names in the query (server returns 400); searching a nonexistent resource type; token/auth failures; queries without pagination limits hitting server-side timeouts; Dataflow workers without API access.
Understand the failure class
Background: "API request failed": what wrapped HTTP errors from external APIs mean and how to find the real cause — this error's family across 29 libraries.
Related errors
- execute bundles entry contains bad status
- could not extract body from execute bundles response
- could not extract body from read resource
- could not parse body from execute bundle response
- could not resolve to a temp directory for import batch files
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/b0d448bdcfe7ca6c.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/go/pkg/beam/io/fhirio/search.go:76
// Path to FHIR store where search will be performed.
FhirStorePath string
}
func (fn searchResourcesFn) String() string {
return "searchResourcesFn"
}
func (fn *searchResourcesFn) Setup() {
fn.fnCommonVariables.setup(fn.String())
}
func (fn *searchResourcesFn) ProcessElement(ctx context.Context, query SearchQuery, emitFoundResources func(string, []string), emitDeadLetter func(string)) {
resourcesFound, err := executeAndRecordLatency(ctx, &fn.latencyMs, func() ([]string, error) {
return fn.searchResources(ctx, query)
})
if err != nil {
fn.resourcesErrorCount.Inc(ctx, 1)
emitDeadLetter(errors.Wrapf(err, "error occurred while performing search for query: [%v]", query).Error())
return
}
fn.resourcesSuccessCount.Inc(ctx, 1)
emitFoundResources(query.Identifier, resourcesFound)
}
func (fn *searchResourcesFn) searchResources(ctx context.Context, query SearchQuery) ([]string, error) {
resourcesInPage, nextPageToken, err := fn.searchResourcesPaginated(ctx, query, "")
allResources := resourcesInPage
for nextPageToken != "" {
resourcesInPage, nextPageToken, err = fn.searchResourcesPaginated(ctx, query, nextPageToken)
allResources = append(allResources, resourcesInPage...)
}
return allResources, err
}
// Performs a search request retrieving results only from the page identified byView on GitHub (pinned to 12126d8942)