{"record":{"id":"eb518ebac8400b1b","repo":"larksuite/cli","slug":"input-terminated-unexpectedly-eof","errorCode":null,"errorMessage":"input terminated unexpectedly (EOF)","messagePattern":"input terminated unexpectedly \\(EOF\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"cmd/config/init.go","lineNumber":505,"sourceCode":"\tif !f.IOStreams.IsTerminal {\n\t\treturn errs.NewValidationError(errs.SubtypeInvalidArgument, \"config init requires a terminal for interactive mode. Run with --new to create a new app:\\n  lark-cli config init --new\\nThis command blocks until setup is complete and outputs a verification URL. Run it in the background, then retrieve the URL from its output.\")\n\t}\n\n\t// Mode 5: Legacy interactive (readline fallback)\n\tfirstApp := (*core.AppConfig)(nil)\n\tif existing != nil {\n\t\tfirstApp = existing.CurrentAppConfig(\"\")\n\t}\n\n\treader := bufio.NewReader(f.IOStreams.In)\n\treadLine := func(prompt string) (string, error) {\n\t\tfmt.Fprintf(f.IOStreams.ErrOut, \"%s: \", prompt)\n\t\tline, err := reader.ReadString('\\n')\n\t\tif err != nil && err != io.EOF {\n\t\t\treturn \"\", fmt.Errorf(\"failed to read input: %w\", err)\n\t\t}\n\t\tif err == io.EOF && strings.TrimSpace(line) == \"\" {\n\t\t\treturn \"\", fmt.Errorf(\"input terminated unexpectedly (EOF)\")\n\t\t}\n\t\treturn strings.TrimSpace(line), nil\n\t}\n\n\tprompt := \"App ID\"\n\tif firstApp != nil && firstApp.AppId != \"\" {\n\t\tprompt += fmt.Sprintf(\" [%s]\", firstApp.AppId)\n\t}\n\tappIdInput, err := readLine(prompt)\n\tif err != nil {\n\t\treturn errs.NewValidationError(errs.SubtypeInvalidArgument, \"%s\", err).WithCause(err)\n\t}\n\n\tprompt = \"App Secret\"\n\tif firstApp != nil && !firstApp.AppSecret.IsZero() {\n\t\tprompt += \" [****]\"\n\t}\n\tappSecretInput, err := readLine(prompt)","sourceCodeStart":487,"sourceCodeEnd":523,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/cmd/config/init.go#L487-L523","documentation":"In `lark-cli config init` legacy interactive mode, when ReadString returns io.EOF and the accumulated line is empty/whitespace, the command reports \"input terminated unexpectedly (EOF)\" because stdin ended before an answer was given. The caller wraps it into a validation error.","triggerScenarios":"Pressing Ctrl-D (EOF) at the App ID / App Secret / Brand prompt with nothing typed; running the interactive command with stdin from an empty file, /dev/null, or a closed pipe in a TTY-claiming environment.","commonSituations":"Aborting the wizard with Ctrl-D instead of Ctrl-C; CI jobs that pass the terminal check but feed empty stdin; terminal multiplexer sessions detaching mid-prompt.","solutions":["Re-run `lark-cli config init` in an interactive terminal and type values, finishing with enter rather than Ctrl-D.","Abort with Ctrl-C if you want to cancel, and use `lark-cli config init --new` for unattended creation.","If scripting, supply config non-interactively (flags/config file/env) instead of relying on the interactive prompts."],"exampleFix":"// before: EOF at prompt\nApp ID: (Ctrl-D) -> input terminated unexpectedly (EOF)\n// after\nApp ID: cli_a1b2c3 (enter)  # or abort with Ctrl-C / use config init --new","handlingStrategy":"fallback","validationCode":"// Detect non-character-device stdin before prompting\nstat, _ := os.Stdin.Stat()\nif stat != nil && (stat.Mode()&os.ModeCharDevice) == 0 {\n\treturn errors.New(\"stdin is not a terminal; refusing interactive prompt\")\n}","typeGuard":null,"tryCatchPattern":"err := runConfigInit()\nif err != nil && strings.Contains(err.Error(), \"input terminated unexpectedly\") {\n\tlog.Println(\"interactive setup aborted at EOF; falling back to config init --new\")\n\treturn runConfigInitNew()\n}","preventionTips":["Cancel prompts with Ctrl-C, not Ctrl-D.","Re-run the wizard rather than answering prompts from files/pipes.","Use `config init --new` for any unattended environment.","Verify terminal multiplexer sessions are attached before starting."],"tags":["io","stdin","eof","cli","interactive"],"backgroundTag":"unexpected-eof-on-stdin","analyzedSha":"7fd6ef3c07182257ce776cdc5a614e122d5bd4b3","analyzedAt":"2026-09-04T21:17:44.649Z","contentChangedAt":"2026-09-04T21:17:44.649Z","schemaVersion":2},"datasetVersion":"2026-09-12T02:17:10.037Z"}