Trying to grab an existing routing strategy by name in a separate module, but the data source keeps throwing a panic. I’m using genesyscloud_routing_strategy data source.
Here’s the block:
data "genesyscloud_routing_strategy" "main_strategy" {
name = "Primary Sales Queue"
}
Running terraform plan gives this error:
│ Error: Data source lookup failed
│
│ with data.genesyscloud_routing_strategy.main_strategy,
│ on main.tf line 5, in data "genesyscloud_routing_strategy" "main_strategy":
│ 5: data "genesyscloud_routing_strategy" "main_strategy" {
│
│ No routing strategy found with name "Primary Sales Queue"
I’ve verified the name in the UI. It matches exactly. Case-sensitive too. There’s only one strategy with that name. I tried adding a description filter, same result. Is the data source doing a partial match or something? Or is there a delay in the provider cache? I’ve been fighting this for an hour. The ID is right there in the state file from the other module, but I need the ID dynamically for the queue config.
Just want to know if I’m missing a parameter or if the provider is broken for name lookups.
The panic usually happens when the provider tries to parse a null response. The genesyscloud_routing_strategy data source is strict. If the name doesn’t match exactly, it returns nothing and crashes the plan.
I ran into this last week with a similar setup. The issue is that routing strategies are often nested under a specific routing queue or skill group, and the global lookup by name alone can be ambiguous or return multiple results if you have test environments running. The provider doesn’t handle the “multiple matches” case well, hence the panic.
Try switching to a REST Proxy approach or using the genesyscloud_routing_skill data source if you’re actually trying to bind it to a queue. But if you just need the strategy ID, here’s a more stable pattern using the genesyscloud_routing_strategy with a specific routing_queue_id constraint. It forces a single result.
data "genesyscloud_routing_strategy" "main_strategy" {
name = "Primary Sales Queue"
routing_queue_id = var.sales_queue_id # Pass the queue ID from the other module
}
If you don’t have the queue ID handy, you might want to use the genesyscloud_routing_strategy resource with lifecycle { ignore_changes = [name] } to import it instead of looking it up. Data sources are finicky with naming conventions.
Also, check your provider version. Older versions had a bug where empty lists caused panics. We’re on 1.8.2 in our production pipelines and it’s much better.
Another gotcha: make sure the strategy isn’t archived. The API filters those out, but the data source might not handle the empty response gracefully.
# Verify via curl if you're stuck
curl -X GET "https://api.mypurecloud.com/api/v2/routing/strategies?name=Primary%20Sales%20Queue" \
-H "Authorization: Bearer $TOKEN"
If the curl returns an empty array, the data source will panic. That’s usually the root cause.