mastra-ai/mastra · error
Factory workspace GitHub credential registration is no longe
Error message
Factory workspace GitHub credential registration is no longer active.
What it means
After workspace construction, `reconcileRegisteredWorkspace` verifies that the GitHub credential registration made during setup is still the one stored for the workspaceId. If the map entry was replaced or deleted while materializing, the workspace's credentials can no longer be trusted, so creation fails fast.
Source
Thrown at mastracode/factory/src/workspace.ts:517
evicted = (await mastra?.removeWorkspace?.(workspaceId)) === true;
} catch {
// Preserve the credential-replacement error and retry on the next reuse.
}
try {
await workspace.destroy();
evicted = true;
} catch {
// The pending registration keeps the workspace quarantined if cleanup also fails.
}
if (evicted && githubTokenInjectors.get(workspaceId) === registered) {
githubTokenInjectors.delete(workspaceId);
constructedWorkspaces.delete(workspaceId);
}
}
throw error;
}
if (registered && githubTokenInjectors.get(workspaceId) !== registered) {
throw new Error('Factory workspace GitHub credential registration is no longer active.');
}
return workspace;
};
let existing: Workspace | undefined;
try {
existing = mastra?.getWorkspaceById(workspaceId) as Workspace | undefined;
} catch {
// Not registered yet.
existing = undefined;
}
existing ??= constructedWorkspaces.get(workspaceId);
if (existing) {
existing.setToolsConfig(MASTRACODE_WORKSPACE_TOOLS);
// A materialization kicked off by another caller may still be running.
// Deliberately do NOT wait for it: a metadata-only resolution (thread
// list, messages, activity) must not block on the clone/setup that lazy
// materialization exists to avoid. Token reconciliation below no-opsView on GitHub (pinned to 75dd419e61)
Solutions
- Retry workspace creation — the conflicting registration will have settled
- Serialize workspace creation per workspaceId (avoid building the same factory concurrently)
- Check for duplicate session/workspace lifecycle events triggering parallel reconciliation
- Add logging on registerGithubTokenInjector to identify which path overwrote the registration
Defensive patterns
Strategy: retry
Validate before calling
const registered = await registerWorkspaceCredentials(workspaceId);
if (githubTokenInjectors.get(workspaceId) !== registered) {
// another reconciliation overwrote registration — retry creation serially
return createWorkspaceFactory(session, { lock: workspaceId });
} Try / catch
try {
const ws = await createWorkspaceFactory(session);
} catch (e) {
if (e instanceof Error && e.message.includes('credential registration is no longer active')) {
const ws = await createWorkspaceFactory(session); // retry after the race settles
} else throw e;
} Prevention
- Serialize createWorkspaceFactory calls per workspaceId (mutex/lock)
- Do not retire or re-register a workspace while its factory is being constructed
- Use a single reconciliation path for GitHub credential registration
- Log registerGithubTokenInjector overwrites to detect concurrent writers
When it happens
Trigger: `createWorkspaceFactory` finishes constructing a workspace with a non-null `registered`, but `githubTokenInjectors.get(workspaceId)` returns a different registration object — another registration replaced it during construction.
Common situations: Two concurrent createWorkspaceFactory/reconciliation calls for the same workspaceId; a teardown/retirement of the workspace interleaved with creation; duplicate workspace factories built for one session.
Related errors
- GitHub token refresh no longer matches the active Factory wo
- Factory session ${session.sessionId} was retired during work
- Factory kickoff was queued onto an ending run and never reac
- Repository access did not include a bearer token for the Fac
- Version-control repository not found.
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/dc9ec2126d731759.
Report an issue: GitHub.