prestodb/presto · warning · WebApplicationException

Query not found

Error message

Query not found

What it means

NimbusOAuth2Client.getTokenResponse wraps failures from the token endpoint exchange (authorization-code or refresh-token grant) as a ChallengeFailedException with the token endpoint's error details appended; authentication cannot proceed without a valid access token.

Source

Thrown at presto-main/src/main/java/com/facebook/presto/server/protocol/LocalQueryProvider.java:196

            }
            query.cancel();
        }

        // cancel the query execution directly instead of creating the statement client
        try {
            if (!queryManager.isQuerySlugValid(queryId, slug)) {
                throw notFound("Query not found");
            }
            queryManager.cancelQuery(queryId);
        }
        catch (NoSuchElementException e) {
            throw notFound("Query not found");
        }
    }

    private static WebApplicationException notFound(String message)
    {
        throw new WebApplicationException(
                Response.status(Status.NOT_FOUND)
                        .type(TEXT_PLAIN_TYPE)
                        .entity(message)
                        .build());
    }
}

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Fetch/hold the queryId from the same LocalQueryProvider submission call before querying or cancelling
  2. Handle 404 as terminal state (query already finished) and skip cancel
  3. Avoid restarting the embedded server between submit and fetch/cancel
  4. Use the dispatcher's completion future to learn query state instead of polling getQuery after completion

Example fix

// before
queryProvider.cancelQuery(queryId); // throws if already finished
// after
try { queryProvider.cancelQuery(queryId); } catch (WebApplicationException e) { if (e.getResponse().getStatus() == 404) return; throw e; }
Defensive patterns

Strategy: try-catch

Validate before calling

// Only use queryIds returned by the same LocalQueryProvider submission in this process lifetime

Type guard

boolean isLiveLocalQuery(LocalQueryProvider provider, QueryId id) { try { provider.getQueryInfo(id); return true; } catch (WebApplicationException e) { return e.getResponse().getStatus() != 404; } }

Try / catch

try { provider.cancelQuery(queryId); } catch (WebApplicationException e) { if (e.getResponse().getStatus() == 404) { /* already gone */ } else throw e; }

Prevention

When it happens

Trigger: Calling getQueryInfo or cancelQuery on the embedded/local dispatcher for a queryId that was never submitted to this instance, already completed and purged, or after restarting the embedded Presto server process.

Common situations: Testing with LocalQueryProvider/embedded server and reusing query IDs across restarts, cancel racing with query completion, clients keeping references to finished queries.

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 prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/fde62b53bb7ff4a1. Report an issue: GitHub.