apache/cassandra · error · IllegalArgumentException

No query defined with name

Error message

No query defined with name ${name}

What it means

getQuery resolves a named query defined in the stress profile YAML. If the name (lowercased for lookup) is not present in the queries map, an IllegalArgumentException is thrown. It guards against referencing queries that were never declared in the profile.

Solutions

  1. Add the missing named query to the 'queries' section of the profile YAML
  2. Fix the typo in the query name used in the stress command/operation spec
  3. List the queries defined in the YAML and pick an existing name
  4. Remember names are lowercased before lookup - use the exact lowercased key

Example fix

# before
stress run profile=my.yaml op=query1
# after (yaml defines 'queries: mainquery: ...')
stress run profile=my.yaml op=mainquery
Defensive patterns

Strategy: validation

Validate before calling

// check the query name is defined in the profile YAML before invoking
Set<String> defined = yamlProfile.getQueries().keySet();
if (!defined.contains(queryName.toLowerCase())) throw new IllegalArgumentException("unknown query: " + queryName);

Try / catch

try { profile.get(name, ...); } catch (IllegalArgumentException e) { if (e.getMessage().startsWith("No query defined")) log.error("Available queries: {}", yamlProfile.getQueries().keySet()); throw e; }

Prevention

When it happens

Trigger: Calling profile.get(...) with an operation/query name that is not declared under the 'queries:' section of the profile YAML (or with wrong case that still does not match after lowercasing).

Common situations: Typos in the query name on the command line or in the YAML, invoking a named query from a different profile file, case mismatches beyond simple lowercasing.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10). Data as JSON: /api/errors/87abe4eda80dcf0e. Report an issue: GitHub.

Appendix: source

Thrown at tools/stress/src/org/apache/cassandra/stress/StressProfile.java:406

                    sortedRanges.add(range);
            }

            Collections.sort(sortedRanges);
            tokenRanges = new LinkedHashSet<>(sortedRanges);
            return tokenRanges;
        }
    }

    public Operation getQuery(String name,
                              Timer timer,
                              PartitionGenerator generator,
                              SeedManager seeds,
                              StressSettings settings,
                              boolean isWarmup)
    {
        name = toLowerCaseLocalized(name);
        if (!queries.containsKey(name))
            throw new IllegalArgumentException("No query defined with name " + name);

        if (queryStatements == null)
        {
            synchronized (this)
            {
                if (queryStatements == null)
                {
                    JavaDriverClient jclient = settings.getJavaDriverClient(keyspaceName);

                    Map<String, PreparedStatement> stmts = new HashMap<>();
                    Map<String, SchemaStatement.ArgSelect> args = new HashMap<>();
                    for (Map.Entry<String, StressYaml.QueryDef> e : queries.entrySet())
                    {
                        stmts.put(toLowerCaseLocalized(e.getKey()), jclient.prepare(e.getValue().cql));
                        args.put(toLowerCaseLocalized(e.getKey()), e.getValue().fields == null
                                ? SchemaStatement.ArgSelect.MULTIROW
                                : SchemaStatement.ArgSelect.valueOf(toUpperCaseLocalized(e.getValue().fields)));
                    }

View on GitHub (pinned to 88fd0f6a0e)