mastra-ai/mastra · error · HTTPException

Stored response was not found

Error message

Stored response ${responseId} was not found

What it means

GET response-by-id handler: findResponseTurnRecordAcrossAgents searches all agents' memory for the given responseId; if no stored turn record matches, the handler throws HTTP 404. It is then caught by handleError and surfaced as 'Error retrieving response'.

Solutions

  1. Confirm the response was originally created with store:true so a turn record exists.
  2. Point the server at the same storage backend the response was written to.
  3. List/re-check recent stored responses to validate the id; regenerate if the record is gone.
  4. Return 404 handling on the client side and start a new conversation.
Defensive patterns

Strategy: try-catch

Validate before calling

// pre-check existence before fetching
const list = await client.getResponses?.({ threadId }) ?? [];
if (!list.some(r => r.id === responseId)) return null;

Try / catch

try {
  return await client.getResponse(responseId);
} catch (e) {
  if (isHttpError(e, 404)) return null; // treat as absent, not fatal
  throw e;
}

Prevention

When it happens

Trigger: GET /api/responses/:responseId (AGENTS_READ) with an id that was never stored, was deleted, or lives in a different storage backend/instance.

Common situations: Client cached a response id after the DB was reset; retrieving across environments (staging vs local dev DB); requesting ids from responses created with store:false; retention cleanup removed the record.

Related errors


AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30). Data as JSON: /api/errors/6679154b0788936c. Report an issue: GitHub.

Appendix: source

Thrown at packages/server/src/server/handlers/responses.ts:1029

  },
});

export const GET_RESPONSE_ROUTE = createRoute({
  method: 'GET',
  path: '/v1/responses/:responseId',
  responseType: 'json',
  pathParamSchema: responseIdPathParams,
  responseSchema: responseObjectSchema,
  summary: 'Retrieve a stored response',
  description: 'Returns a previously stored response object',
  tags: ['Responses'],
  requiresAuth: true,
  requiresPermission: MastraFGAPermissions.AGENTS_READ,
  handler: async ({ mastra, requestContext, responseId }) => {
    try {
      const responseTurnRecord = await findResponseTurnRecordAcrossAgents({ mastra, responseId, requestContext });
      if (!responseTurnRecord) {
        throw new HTTPException(404, { message: `Stored response ${responseId} was not found` });
      }

      return mapResponseTurnRecordToResponse(responseTurnRecord);
    } catch (error) {
      return handleError(error, 'Error retrieving response');
    }
  },
});

export const DELETE_RESPONSE_ROUTE = createRoute({
  method: 'DELETE',
  path: '/v1/responses/:responseId',
  responseType: 'json',
  pathParamSchema: responseIdPathParams,
  responseSchema: deleteResponseSchema,
  summary: 'Delete a stored response',
  description: 'Deletes a stored response so it can no longer be retrieved or chained',
  tags: ['Responses'],

View on GitHub (pinned to 75dd419e61)