{"record":{"id":"f2fd8a73f42dfab2","repo":"mastra-ai/mastra","slug":"commit-failed","errorCode":"commit-failed","errorMessage":"Failed to set git user.name: ${setName.stderr.trim()}","messagePattern":"Failed to set git user\\.name: (.+?)","errorType":"error_code","errorClass":"MaterializeError","httpStatus":null,"severity":"error","filePath":"mastracode/factory/src/integrations/github/sandbox.ts","lineNumber":660,"sourceCode":"  const email =\n    (identity.email || '').trim() ||\n    (login ? `${login}@users.noreply.github.com` : 'mastra-code@users.noreply.github.com');\n  return { name, email };\n}\n\n/**\n * Configure `user.name` / `user.email` for the given repo working tree inside\n * the sandbox so commits are authored correctly. Values are shell-quoted.\n */\nexport async function configureGitIdentity(\n  sandbox: ExecutableSandbox,\n  workdir: string,\n  identity: GitIdentity,\n): Promise<void> {\n  const { name, email } = resolveGitIdentity(identity);\n  const setName = await sh(sandbox, `git -C ${shellQuote(workdir)} config user.name ${shellQuote(name)}`);\n  if (setName.exitCode !== 0) {\n    throw new MaterializeError(`Failed to set git user.name: ${setName.stderr.trim()}`, 'commit-failed');\n  }\n  const setEmail = await sh(sandbox, `git -C ${shellQuote(workdir)} config user.email ${shellQuote(email)}`);\n  if (setEmail.exitCode !== 0) {\n    throw new MaterializeError(`Failed to set git user.email: ${setEmail.stderr.trim()}`, 'commit-failed');\n  }\n}\n\n/**\n * Temporarily rewrite `origin` to a tokenized URL, run `fn` (e.g. a push), and\n * **always** scrub the remote back to the tokenless URL afterwards. The token\n * therefore only ever lives in the remote URL for the duration of the\n * operation and is never left in the VM's git config.\n *\n * Once the tokenized URL is installed a failed scrub may leave the token\n * persisted, so it is always surfaced: on its own after a successful `fn`,\n * appended to `fn`'s own error otherwise — `fn`'s error is never replaced.\n * Only a failed set-url (the token never reached the remote) downgrades the\n * scrub to best-effort.","sourceCodeStart":642,"sourceCodeEnd":678,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/mastracode/factory/src/integrations/github/sandbox.ts#L642-L678","documentation":"configureGitIdentity sets `git config user.name` (and then user.email) in the session workdir before commits; a non-zero exit from the user.name command throws this MaterializeError with code commit-failed and the trimmed git stderr. Without an identity, git commits would fail, so the library aborts the commit flow early.","triggerScenarios":"`git -C <workdir> config user.name <name>` failing because the workdir isn't a git repository (.git missing), the filesystem is read-only/full, the shell-quoted identity contains characters git rejects, or git is missing/broken in the sandbox.","commonSituations":"Sandbox disk quota exceeded; .git removed by session activity; custom GitIdentity values that upset git config parsing; sandbox image without git (usually caught earlier by the git-missing preflight).","solutions":["Inspect the trimmed stderr in the message for the concrete git error.","Confirm the workdir still contains a valid .git directory; re-materialize if it was wiped.","Free disk space or fix permissions if the error is ENOSPC/EACCES.","Simplify the GitIdentity name/email to plain ASCII values and retry commitAll."],"exampleFix":"// before\nidentity = { name: 'Agent O\\'Brien \\u2013 bot', email: 'not-an-email' };\n// after\nidentity = { name: 'mastra-agent', email: 'agent@example.com' };","handlingStrategy":"try-catch","validationCode":"const { name, email } = resolveGitIdentity(identity);\nif (!/^[^\\n\\r;|&$`<>]+$/.test(name) || !/^[^@\\s]+@[^@\\s]+\\.[^@\\s]+$/.test(email)) {\n  throw new Error('GitIdentity name/email must be simple, valid values');\n}","typeGuard":"const isPlainIdentity = (i: GitIdentity): boolean => {\n  const { name, email } = resolveGitIdentity(i);\n  return name.length > 0 && !/[\\n\\r]/.test(name) && /^[^@\\s]+@[^@\\s]+$/.test(email);\n};","tryCatchPattern":"try {\n  await commitAll(sandbox, workdir, identity);\n} catch (err) {\n  if (err instanceof MaterializeError && err.code === 'commit-failed' && err.message.includes('user.name')) {\n    throw new Error(`git config user.name failed in sandbox: ${err.message}`, { cause: err });\n  }\n  throw err;\n}","preventionTips":["Keep GitIdentity values simple ASCII (name and email) to avoid config parsing issues.","Check sandbox disk space before commit flows; ENOSPC is a frequent cause.","Verify the session workdir still has a valid .git before committing.","Confirm git identity once per session instead of assuming prior configuration."],"tags":["git","sandbox","commit","configuration"],"backgroundTag":"git-command-failed","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}