{"record":{"id":"74c82ab530d84bd0","repo":"eyaltoledano/claude-task-master","slug":"config-error","errorCode":"CONFIG_ERROR","errorMessage":"'No organization selected. Run \"tm context org\" first.'","messagePattern":"'No organization selected\\. Run \"tm context org\" first\\.'","errorType":"exception","errorClass":"TaskMasterError","httpStatus":null,"severity":"error","filePath":"packages/tm-core/src/modules/briefs/briefs-domain.ts","lineNumber":73,"sourceCode":"\t\t\t\t\t(org) =>\n\t\t\t\t\t\torg.slug?.toLowerCase() === parsed.orgSlug?.toLowerCase() ||\n\t\t\t\t\t\torg.name.toLowerCase() === parsed.orgSlug?.toLowerCase()\n\t\t\t\t);\n\t\t\t\tif (matchingOrg) {\n\t\t\t\t\tresolvedOrgId = matchingOrg.id;\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t// If we can't fetch orgs, fall through to context\n\t\t\t}\n\t\t}\n\n\t\t// Fall back to context if still not resolved\n\t\tif (!resolvedOrgId) {\n\t\t\tresolvedOrgId = this.authManager.getContext()?.orgId;\n\t\t}\n\n\t\tif (!resolvedOrgId) {\n\t\t\tthrow new TaskMasterError(\n\t\t\t\t'No organization selected. Run \"tm context org\" first.',\n\t\t\t\tERROR_CODES.CONFIG_ERROR\n\t\t\t);\n\t\t}\n\n\t\t// Fetch all briefs for the org\n\t\tconst briefs = await this.authManager.getBriefs(resolvedOrgId);\n\n\t\t// Find matching brief using service\n\t\tconst matchingBrief = await this.briefService.findBrief(\n\t\t\tbriefs,\n\t\t\tbriefIdOrName\n\t\t);\n\n\t\tthis.briefService.validateBriefFound(matchingBrief, briefIdOrName);\n\n\t\treturn matchingBrief;\n\t}","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/packages/tm-core/src/modules/briefs/briefs-domain.ts#L55-L91","documentation":"resolveBrief in BriefsDomain requires an organization ID to fetch briefs. It tries explicit inputs first, then falls back to the auth manager's context orgId; if neither exists it throws TaskMasterError with code CONFIG_ERROR telling the user to run 'tm context org'. It is a configuration/state error, not a network failure.","triggerScenarios":"Calling resolveBrief (or any flow that uses it, e.g. matchingBrief) before the user has logged in / selected an organization, so neither the input nor authManager.getContext()?.orgId yields an org ID.","commonSituations":"Fresh install where the user never ran 'tm context org'; stale/expired session clearing context; running brief commands in CI without provisioning context; switching machines without migrating config.","solutions":["Run `tm context org` to select the organization, then retry the command","Run `tm auth login` first if there is no session at all, then set context","Pass the organization explicitly if the calling API accepts an org ID parameter","In scripts/CI, provision context non-interactively before invoking brief operations"],"exampleFix":"// before\nawait tmCore.briefs.resolveBrief('my-brief'); // throws CONFIG_ERROR\n// after\nif (!tmCore.auth.getContext()?.orgId) {\n  await tmCore.context.setOrg('my-org'); // or shell out: tm context org\n}\nawait tmCore.briefs.resolveBrief('my-brief');","handlingStrategy":"validation","validationCode":"const ctx = tmCore.auth.getContext();\nif (!ctx?.orgId) {\n  throw new Error('No org selected — run `tm context org` or set context before brief operations');\n}","typeGuard":"function hasOrgContext(ctx: AuthContext | null | undefined): ctx is AuthContext & { orgId: string } {\n  return typeof ctx?.orgId === 'string' && ctx.orgId.length > 0;\n}","tryCatchPattern":"try {\n  brief = await tmCore.briefs.resolveBrief(nameOrId);\n} catch (e) {\n  if (e instanceof TaskMasterError && e.code === 'CONFIG_ERROR') {\n    await tmCore.context.setOrg(orgId); // then retry once\n  } else { throw e; }\n}","preventionTips":["After `tm auth login`, always run `tm context org` before brief commands","In CI, assert org context exists as a preflight step instead of failing mid-run","Check authManager.getContext()?.orgId before invoking any briefs-domain API","Persist context so scripts across sessions don't lose the org selection"],"tags":["config","organization","context","state"],"backgroundTag":"missing-org-context","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}