{"record":{"id":"4e0cedeb5808a733","repo":"multica-ai/multica","slug":"workspace-id-is-required-multica-workspace-id-mus","errorCode":null,"errorMessage":"workspace_id is required: MULTICA_WORKSPACE_ID must be set by the daemon in agent execution context (no fallback to user config)","messagePattern":"workspace_id is required: MULTICA_WORKSPACE_ID must be set by the daemon in agent execution context \\(no fallback to user config\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/cmd/multica/cmd_agent.go","lineNumber":503,"sourceCode":"\t}\n\t// Inside an agent task the daemon is the only authority on workspace\n\t// identity. Never read the user-global CLI config here.\n\tif inDaemonManagedExecutionContext() {\n\t\treturn \"\"\n\t}\n\tprofile := resolveProfile(cmd)\n\tcfg, _ := cli.LoadCLIConfigForProfile(profile)\n\treturn cfg.WorkspaceID\n}\n\n// requireWorkspaceID resolves the workspace ID and returns an error with\n// actionable instructions if it is empty (e.g. user has multiple workspaces\n// but no default configured).\nfunc requireWorkspaceID(cmd *cobra.Command) (string, error) {\n\tid := resolveWorkspaceID(cmd)\n\tif id == \"\" {\n\t\tif inDaemonManagedExecutionContext() {\n\t\t\treturn \"\", fmt.Errorf(\"workspace_id is required: MULTICA_WORKSPACE_ID must be set by the daemon in agent execution context (no fallback to user config)\")\n\t\t}\n\t\treturn \"\", fmt.Errorf(\"workspace_id is required: use --workspace-id flag, set MULTICA_WORKSPACE_ID env, or run 'multica config set workspace_id <id>'\")\n\t}\n\treturn id, nil\n}\n\n// ---------------------------------------------------------------------------\n// Agent commands\n// ---------------------------------------------------------------------------\n\nfunc runAgentList(cmd *cobra.Command, _ []string) error {\n\tclient, err := newAPIClient(cmd)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif client.WorkspaceID == \"\" {\n\t\tif _, err := requireWorkspaceID(cmd); err != nil {\n\t\t\treturn err","sourceCodeStart":485,"sourceCodeEnd":521,"githubUrl":"https://github.com/multica-ai/multica/blob/2c0912b6ec764b373d44eeea1e80f0d9f11ab417/server/cmd/multica/cmd_agent.go#L485-L521","documentation":"requireWorkspaceID found no workspace ID while in daemon-managed execution context. There is deliberately no fallback to user config in agent context: the daemon must inject MULTICA_WORKSPACE_ID, and its absence means the task runtime mis-injected the environment — the error says so instead of silently using the human's default workspace.","triggerScenarios":"inDaemonManagedExecutionContext() is true and MULTICA_WORKSPACE_ID is empty while neither --workspace-id nor config provides an ID (config fallback is intentionally suppressed here).","commonSituations":"Custom task wrappers or Docker-based runtimes that whitelist env vars and drop MULTICA_WORKSPACE_ID; a daemon bug that only injects it for certain task types; leaking daemon context vars into a human shell.","solutions":["If human shell: unset the daemon context variables so the normal flag/config fallback applies.","If real task: fix the runtime to export MULTICA_WORKSPACE_ID alongside the mat_ token and agent/task IDs.","As a stopgap, pass --workspace-id explicitly on the command."],"exampleFix":"# before: task wrapper forgets the workspace\nexport MULTICA_TOKEN=mat_...\nmultica issue list  # -> workspace_id is required ...\n\n# after: inject it like the daemon does\nexport MULTICA_TOKEN=mat_...\nexport MULTICA_WORKSPACE_ID=ws_123\nmultica issue list","handlingStrategy":"validation","validationCode":"// Custom runtimes: assert the daemon-style injection set is complete.\nrequired := map[string]string{\n    \"MULTICA_TOKEN\":         os.Getenv(\"MULTICA_TOKEN\"),\n    \"MULTICA_WORKSPACE_ID\":  os.Getenv(\"MULTICA_WORKSPACE_ID\"),\n}\nfor k, v := range required {\n    if v == \"\" {\n        return fmt.Errorf(\"missing required task env %s\", k)\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always inject MULTICA_WORKSPACE_ID together with the mat_ token in task envs.","Do not strip env vars in container/wrapper allowlists without re-adding the multica set.","If you intentionally want config fallback, run outside daemon context (clean shell)."],"tags":["go","cli","daemon","configuration","environment"],"backgroundTag":null,"analyzedSha":"2c0912b6ec764b373d44eeea1e80f0d9f11ab417","analyzedAt":"2026-08-15T13:25:18.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}