{"record":{"id":"4bf44884443f8080","repo":"multica-ai/multica","slug":"token-is-required","errorCode":null,"errorMessage":"token is required","messagePattern":"token is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/cmd/multica/cmd_auth.go","lineNumber":430,"sourceCode":"\nfunc runAuthLoginToken(cmd *cobra.Command, providedToken string) error {\n\t// The prompt sentinel is what pflag substitutes for `--token` with no\n\t// value (see loginCmd init); treat it the same as an empty string so we\n\t// fall through to the interactive prompt.\n\tif providedToken == tokenPromptSentinel {\n\t\tprovidedToken = \"\"\n\t}\n\ttoken := strings.TrimSpace(providedToken)\n\tif token == \"\" {\n\t\tfmt.Print(\"Enter your personal access token: \")\n\t\tscanner := bufio.NewScanner(os.Stdin)\n\t\tif !scanner.Scan() {\n\t\t\treturn fmt.Errorf(\"no input\")\n\t\t}\n\t\ttoken = strings.TrimSpace(scanner.Text())\n\t}\n\tif token == \"\" {\n\t\treturn fmt.Errorf(\"token is required\")\n\t}\n\tif err := validateLoginTokenPrefix(token); err != nil {\n\t\treturn err\n\t}\n\n\tserverURL := resolveLoginTokenServerURL(cmd)\n\tclient := cli.NewAPIClient(serverURL, \"\", token)\n\n\tctx, cancel := cli.APIContext(context.Background())\n\tdefer cancel()\n\n\tvar me struct {\n\t\tName  string `json:\"name\"`\n\t\tEmail string `json:\"email\"`\n\t}\n\tif err := client.GetJSON(ctx, \"/api/me\", &me); err != nil {\n\t\treturn cli.WithUserMessage(\"Could not sign in with that token — make sure it is valid and not expired, then run `multica login --token <token>` again.\", err)\n\t}","sourceCodeStart":412,"sourceCodeEnd":448,"githubUrl":"https://github.com/multica-ai/multica/blob/2c0912b6ec764b373d44eeea1e80f0d9f11ab417/server/cmd/multica/cmd_auth.go#L412-L448","documentation":"Token login reached the point where the token string is still empty after trimming the provided value and (if prompted) the entered line. An explicitly empty token is rejected before any validation or network call.","triggerScenarios":"Pressing Enter at the token prompt without typing anything; passing `--token ''` or `--token` with only whitespace; the sentinel value for valueless --token plus an empty stdin line.","commonSituations":"Users unsure whether the prompt is pre-filled and pressing Enter; scripts passing an unset environment variable that expands to empty; copy failures leaving the clipboard empty.","solutions":["Enter or pass a real PAT beginning with mul_ (or the cloud PAT prefix)","In scripts, guard before invoking: fail fast if $MULTICA_TOKEN is empty","Re-copy the token and paste again at the prompt"],"exampleFix":"# shell guard before login\n[ -n \"$MULTICA_TOKEN\" ] || { echo 'MULTICA_TOKEN is empty' >&2; exit 1; }\nmultica login --token \"$MULTICA_TOKEN\"","handlingStrategy":"validation","validationCode":"[ -n \"$(trim \"$MULTICA_TOKEN\")\" ] || { echo 'token is empty' >&2; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Fail fast in scripts when the token variable is unset or empty","Confirm the paste actually landed at the prompt before pressing Enter"],"tags":["cli","auth","validation","token","login"],"backgroundTag":null,"analyzedSha":"2c0912b6ec764b373d44eeea1e80f0d9f11ab417","analyzedAt":"2026-08-15T13:25:18.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}