mastra-ai/mastra · error · Error
Failed to fetch logs: ${error.detail}
Error message
Failed to fetch logs: ${error.detail} What it means
Thrown by getLogs in the CLI's studio deploy-logs command when the platform API returns an error response for the deploy logs fetch. The error carries the API-provided `detail` field, so the message reflects the server's reason (auth failure, unknown deploy ID, permissions, etc.).
Source
Thrown at packages/cli/src/commands/studio/deploy-logs.ts:15
import { writeBarLine } from '../../utils/clack-bar.js';
import { authHeaders, createApiClient, MASTRA_PLATFORM_API_URL, platformFetch } from '../auth/client.js';
import { getToken, getCurrentOrgId, validateOrgAccess } from '../auth/credentials.js';
async function getLogs(deployId: string, tail: string | undefined, token: string, orgId: string) {
const client = createApiClient(token, orgId);
const { data, error } = await client.GET('/v1/studio/deploys/{id}/logs', {
params: {
path: { id: deployId },
query: tail ? { tail } : undefined,
},
});
if (error) {
throw new Error(`Failed to fetch logs: ${error.detail}`);
}
if (data.logs) {
for (const line of data.logs.split('\n')) {
if (line) await writeBarLine(line);
}
} else {
console.info('(no logs available)');
}
}
async function streamLogs(deployId: string, token: string, orgId: string) {
const url = `${MASTRA_PLATFORM_API_URL}/v1/studio/deploys/${deployId}/logs/stream`;
const resp = await platformFetch(url, {
headers: {
...authHeaders(token, orgId),
Accept: 'text/event-stream',View on GitHub (pinned to 75dd419e61)
Solutions
- Read the `error.detail` in the message — it states the server's specific reason; fix accordingly.
- Re-authenticate (`mastra login` or equivalent) if the detail indicates auth/permission problems.
- Verify the deploy ID is correct and belongs to your organization.
- Retry later if the detail indicates a server-side (5xx) problem.
Defensive patterns
Strategy: try-catch
Validate before calling
// verify auth and deploy ID before fetching
const projects = await fetchProjects(token, orgId);
const known = projects.some(p => p.latestDeployId === deployId);
if (!known) throw new Error(`Deploy ${deployId} not found in org ${orgId}; check the ID and your login.`); Type guard
function hasDetail(e: unknown): e is { detail: string } {
return typeof e === 'object' && e !== null && 'detail' in e && typeof (e as any).detail === 'string';
} Try / catch
try {
await getLogs(deployId, tail);
} catch (err) {
if ((err as Error).message.startsWith('Failed to fetch logs:')) {
console.error(err.message); // server detail included
console.error('Re-authenticate (`mastra login`) or verify the deploy ID.');
return;
}
throw err;
} Prevention
- Copy deploy IDs from command output rather than typing them.
- Re-authenticate regularly to avoid expired tokens.
- Confirm the deploy belongs to the organization you're logged into.
- Check platform status before diagnosing as a local problem.
When it happens
Trigger: Calling `mastra studio deploy logs <deploy-id>` when the API call returns an error: invalid or expired token, deploy ID that does not exist, deploy belonging to another organization, or a server-side error surfaced via error.detail.
Common situations: Typo'd or stale deploy ID; logged-in account lacking access to the project's organization; expired CLI auth token; platform API returning 4xx/5xx details during incidents.
Related errors
- No upload URL returned
- Failed to fetch templates: ${response.statusText}
- Telegram ${method} failed: ${detail}
- Perplexity Search request failed with status ${response.stat
- ${err instanceof Error ? err.message : String(err)}\nYou can
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/618c763b5a822f9e.
Report an issue: GitHub.