{"record":{"id":"4fee1a13a7144e6e","repo":"multica-ai/multica","slug":"multica-daemon-port-not-set-this-command-is-inten","errorCode":null,"errorMessage":"MULTICA_DAEMON_PORT not set (this command is intended to be run by an agent inside a daemon task)","messagePattern":"MULTICA_DAEMON_PORT not set \\(this command is intended to be run by an agent inside a daemon task\\)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/cmd/multica/cmd_repo.go","lineNumber":340,"sourceCode":"\t}\n\toutput, _ := cmd.Flags().GetString(\"output\")\n\tif output == \"json\" {\n\t\treturn cli.PrintJSON(os.Stdout, result)\n\t}\n\trows := make([][]string, 0, len(removed))\n\tfor _, repo := range removed {\n\t\trows = append(rows, []string{repo.URL, repo.Description})\n\t}\n\tcli.PrintTable(os.Stdout, []string{\"REMOVED URL\", \"DESCRIPTION\"}, rows)\n\treturn nil\n}\n\nfunc runRepoCheckout(cmd *cobra.Command, args []string) error {\n\trepoURL := args[0]\n\n\tdaemonPort := os.Getenv(\"MULTICA_DAEMON_PORT\")\n\tif daemonPort == \"\" {\n\t\treturn fmt.Errorf(\"MULTICA_DAEMON_PORT not set (this command is intended to be run by an agent inside a daemon task)\")\n\t}\n\n\tworkspaceID := os.Getenv(\"MULTICA_WORKSPACE_ID\")\n\tagentName := os.Getenv(\"MULTICA_AGENT_NAME\")\n\ttaskID := os.Getenv(\"MULTICA_TASK_ID\")\n\n\t// Use current working directory as the checkout target.\n\tworkDir, err := os.Getwd()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"get working directory: %w\", err)\n\t}\n\n\treqBody := map[string]any{\n\t\t\"url\":           repoURL,\n\t\t\"workspace_id\":  workspaceID,\n\t\t\"workdir\":       workDir,\n\t\t\"ref\":           repoCheckoutRef,\n\t\t\"agent_name\":    agentName,","sourceCodeStart":322,"sourceCodeEnd":358,"githubUrl":"https://github.com/multica-ai/multica/blob/2c0912b6ec764b373d44eeea1e80f0d9f11ab417/server/cmd/multica/cmd_repo.go#L322-L358","documentation":"runRepoCheckout refuses to run when the MULTICA_DAEMON_PORT environment variable is empty. Unlike the other repo subcommands it does not talk to the main API; it POSTs to a local daemon at http://127.0.0.1:$PORT/repo/checkout, and that port is only injected when the multica daemon spawns the command inside an agent task.","triggerScenarios":"Running `multica repo checkout <url>` manually from a plain shell (not from within a daemon-spawned agent task), so MULTICA_DAEMON_PORT was never set; or a task runner that clears the environment before executing the command.","commonSituations":"A developer trying to test checkout locally; an agent whose execution environment is sanitized (env -i, docker exec without -e, systemd service without PassEnvironment), dropping daemon-injected vars.","solutions":["Run the command from inside a daemon task (the intended context) — e.g. instruct the agent to run it, so the daemon sets MULTICA_DAEMON_PORT.","For manual testing, set the variable to the actual daemon port: query the daemon process/config for its listen port, then MULTICA_DAEMON_PORT=<port> multica repo checkout <url>.","If wrapping in a subprocess, forward the environment: exec.Command with os.Environ(), or docker exec -e MULTICA_DAEMON_PORT."],"exampleFix":"# before (plain shell)\nmultica repo checkout https://github.com/acme/api\n# error: MULTICA_DAEMON_PORT not set\n\n# after (manual test)\nMULTICA_DAEMON_PORT=8123 multica repo checkout https://github.com/acme/api","handlingStrategy":"validation","validationCode":"port := os.Getenv(\"MULTICA_DAEMON_PORT\")\nif port == \"\" {\n\treturn fmt.Errorf(\"not inside a daemon task; set MULTICA_DAEMON_PORT or run via the daemon\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Reserve `multica repo checkout` for daemon-spawned agent tasks; use plain git locally.","When spawning subprocesses from an agent, forward os.Environ() so daemon vars survive.","For manual tests, always export MULTICA_DAEMON_PORT to the daemon's real listen port first."],"tags":["go","cli","environment-variable","daemon","usage-error"],"backgroundTag":null,"analyzedSha":"2c0912b6ec764b373d44eeea1e80f0d9f11ab417","analyzedAt":"2026-08-15T13:25:18.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}