mastra-ai/mastra · error
Failed to load pull request subscriptions (${response.status
Error message
Failed to load pull request subscriptions (${response.status}). What it means
listPullRequestSubscriptions fetches GET /web/github/subscriptions and throws immediately if the HTTP response is not ok, with a message embedding the status code. Unlike the generic request helpers, it does not attempt to read a server error message; the failure is reported purely as 'Failed to load pull request subscriptions (<status>).'.
Source
Thrown at mastracode/factory-ui/src/ui/domains/factory/services/githubSubscriptions.ts:47
typeof value.repoFullName === 'string' &&
typeof value.pullRequestNumber === 'number' &&
Number.isInteger(value.pullRequestNumber) &&
value.pullRequestNumber > 0 &&
isPullRequestStatus(value.status) &&
typeof value.url === 'string'
);
}
export async function listPullRequestSubscriptions(
baseUrl: string,
resourceId: string,
threadId: string,
projectPath?: string,
): Promise<PullRequestSubscription[]> {
const params = new URLSearchParams({ resourceId, threadId });
if (projectPath) params.set('scope', projectPath);
const response = await fetch(`${baseUrl}/web/github/subscriptions?${params}`, { credentials: 'include' });
if (!response.ok) throw new Error(`Failed to load pull request subscriptions (${response.status}).`);
const body: unknown = await response.json();
if (!isRecord(body) || !Array.isArray(body.subscriptions)) {
throw new Error('Pull request subscriptions returned an invalid response.');
}
// one bad row must not hide every other pull request; warn so a widened server enum is not silent
const subscriptions = body.subscriptions.filter(isPullRequestSubscription);
const dropped = body.subscriptions.length - subscriptions.length;
if (dropped > 0 && import.meta.env.DEV) {
console.warn(`Dropped ${dropped} pull request subscription(s) the client does not understand.`);
}
return subscriptions;
}
View on GitHub (pinned to 75dd419e61)
Solutions
- Check the numeric status in the message and inspect the failing request in the network tab
- Re-authenticate so a valid session cookie is sent with credentials: 'include'
- Verify baseUrl points at the server exposing /web/github/subscriptions and that resourceId/threadId are non-empty
- If scope (projectPath) was passed, confirm it matches a project the server knows; try omitting it
Example fix
// before
const subs = await listPullRequestSubscriptions(baseUrl, resourceId, threadId, staleProjectPath);
// after
if (!resourceId || !threadId) throw new Error('resourceId and threadId are required');
const subs = await listPullRequestSubscriptions(baseUrl, resourceId, threadId); Defensive patterns
Strategy: retry
Validate before calling
if (!isNonEmptyString(resourceId) || !isNonEmptyString(threadId)) throw new Error('resourceId and threadId are required for subscriptions');
if (!baseUrl.startsWith('http')) throw new Error('Invalid baseUrl'); Type guard
function isPullRequestSubscription(v: unknown): v is PullRequestSubscription {
return typeof v === 'object' && v !== null && 'id' in v && typeof (v as { id: unknown }).id === 'string';
} Try / catch
async function loadSubscriptions(): Promise<PullRequestSubscription[]> {
try {
return await listPullRequestSubscriptions(baseUrl, resourceId, threadId, projectPath);
} catch (err) {
const msg = err instanceof Error ? err.message : String(err);
if (/401/.test(msg)) { await reauth(); return loadSubscriptions(); }
if (/5\d\d|Failed to load/.test(msg)) { await delay(1000); return loadSubscriptions(); }
throw err;
}
} Prevention
- Ensure session cookies are fresh before calling authenticated /web routes
- Omit the scope param when projectPath is not a confirmed server-known scope
- Confirm the server version mounts /web/github/subscriptions
- Use exponential backoff for transient 5xx failures
When it happens
Trigger: Any non-OK response from GET {baseUrl}/web/github/subscriptions?resourceId=...&threadId=...[&scope=projectPath] with credentials: 'include' — e.g. 401 when the session cookie is missing/expired, 403 when projectPath scope is not permitted, 404 if the web route is absent, or 5xx server error.
Common situations: User session expired so credentials: 'include' carries no valid cookie, passing a projectPath the server does not recognize as a scope, calling before the GitHub web routes are mounted in a dev/proxy misconfiguration, or backend outage.
Related errors
- Perplexity Search request failed with status ${response.stat
- Request failed (${response.status}) / server-provided messag
- Request failed (${res.status}) / server-provided message
- Pull request subscriptions returned an invalid response.
- Request failed (${res.status}) / server-provided message
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/d68cabb336a05f48.
Report an issue: GitHub.