mastra-ai/mastra · error
Linear API returned no data.
Error message
Linear API returned no data.
What it means
After a 200 response with no GraphQL `errors`, `linearGraphql` still requires a `data` key; if `body.data` is absent or falsy it throws this message. Linear's GraphQL contract is that a 200 response without errors carries a `data` object, so its absence means an unexpected or malformed response from Linear.
Source
Thrown at mastracode/factory/src/integrations/linear/integration.ts:265
// Linear returns GraphQL errors (validation, missing scopes, …) with a
// 400 status — surface the actual message instead of just the code.
let detail: string | null = null;
try {
const errBody = (await res.json()) as { errors?: Array<{ message?: string }> };
detail = errBody.errors?.[0]?.message ?? null;
} catch {
// Non-JSON error body; fall back to the status code alone.
}
const err = new Error(`Linear API request failed (${res.status})${detail ? `: ${detail}` : ''}`);
(err as { status?: number }).status = res.status;
throw err;
}
const body = (await res.json()) as { data?: T; errors?: Array<{ message?: string }> };
if (body.errors?.length) {
throw new Error(`Linear API error: ${body.errors[0]?.message ?? 'unknown error'}`);
}
if (!body.data) {
throw new Error('Linear API returned no data.');
}
return body.data;
}
export class LinearIntegration implements FactoryIntegration {
/** Stable integration identifier (see `../base.ts`). */
readonly id = 'linear';
/** Bound once by the factory via `initialize()` before any surface is used. */
#storage: LinearStorageHandle | undefined;
#projects: FactoryProjectsStorage | undefined;
#auth: RouteAuth | undefined;
/** Bind Linear's slice of the generic integration storage, the projects domain, and the host auth seam. */
initialize({
storage,
projects,
auth,
}: {View on GitHub (pinned to 75dd419e61)
Solutions
- Retry the request once — transient empty bodies usually resolve on the next call.
- Log the raw response body around `linearGraphql` to see what actually came back.
- If behind a proxy, check whether the proxy or a security product is rewriting the response.
- If mocking Linear in tests, make fixtures mirror Linear's shape: `{ data: { ... } }`.
- Check Linear's status page / changelog for API behavior changes if it persists.
Example fix
// test fixture before (no data key)
mockResponse = { status: 200, body: {} };
// after
mockResponse = { status: 200, body: { data: { organization: { name: 'Acme', urlKey: 'acme' } } } }; Defensive patterns
Strategy: retry
Validate before calling
const res = await fetch(LINEAR_GRAPHQL_URL, { ...opts });
const text = await res.text();
const body = JSON.parse(text);
if (res.ok && !body.errors && !body.data) {
throw new Error('Malformed Linear response: 200 without data — likely a proxy/mocks issue');
} Type guard
function hasData<T>(body: unknown): body is { data: T } {
return typeof body === 'object' && body !== null && 'data' in body && (body as { data?: unknown }).data != null;
} Try / catch
try {
return await integration.someGraphqlCall();
} catch (err) {
if (err instanceof Error && err.message === 'Linear API returned no data.') {
await sleep(500);
return await integration.someGraphqlCall(); // retry once
}
throw err;
} Prevention
- Make test fixtures mirror Linear's `{ data: ... }` envelope.
- Audit proxies/gateways in front of api.linear.app for body rewrites.
- Retry once on this error before surfacing to users.
- Monitor Linear's status page during incidents.
When it happens
Trigger: Linear (or an intermediary proxy/gateway) returns a 200 JSON body lacking `data` — e.g. an empty object `{}`, a proxy's HTML-to-JSON fallback, or an API change where a query returns null data without an errors array. Any `linearGraphql`-based call (fetchWorkspace, listProjects, listActiveIssues, comment mutations) can hit it.
Common situations: Corporate proxies or local mocks returning `{}` with 200; intercepting Linear traffic in tests with incomplete fixtures; transient Linear incidents returning empty bodies; querying a field whose value is null at the top level after a deprecation.
Related errors
- Linear API error: ${body.errors[0]?.message ?? 'unknown erro
- Linear ${label} returned no access token.
- Token exchange failed: ${error}
- Failed to fetch user info from Auth0
- Token exchange failed: ${error}
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/55d306cf432d98d7.
Report an issue: GitHub.