{"record":{"id":"e53f9f6598b1850b","repo":"passbolt/passbolt_api","slug":"this-is-not-a-valid-answer-please-choose-y-or-n","errorCode":null,"errorMessage":"This is not a valid answer. Please choose Y or n.","messagePattern":"This is not a valid answer\\. Please choose Y or n\\.","errorType":"console","errorClass":"Exception","httpStatus":null,"severity":"warning","filePath":"src/Console/Installer.php","lineNumber":70,"sourceCode":"     * @throws \\Exception Exception raised by validator.\n     * @return void\n     */\n    public static function postInstall(Event $event): void\n    {\n        $io = $event->getIO();\n\n        $rootDir = dirname(dirname(__DIR__));\n\n        static::createAppConfig($rootDir, $io);\n        static::createWritableDirectories($rootDir, $io);\n\n        // ask if the permissions should be changed\n        if ($io->isInteractive()) {\n            $validator = function ($arg) {\n                if (in_array($arg, ['Y', 'y', 'N', 'n'])) {\n                    return $arg;\n                }\n                throw new Exception('This is not a valid answer. Please choose Y or n.');\n            };\n            $setFolderPermissions = $io->askAndValidate(\n                '<info>Set Folder Permissions ? (Default to Y)</info> [<comment>Y,n</comment>]? ',\n                $validator,\n                10,\n                'Y'\n            );\n\n            if (in_array($setFolderPermissions, ['Y', 'y'])) {\n                static::setFolderPermissions($rootDir, $io);\n            }\n        } else {\n            static::setFolderPermissions($rootDir, $io);\n        }\n\n        static::setSecuritySalt($rootDir, $io);\n    }\n","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/src/Console/Installer.php#L52-L88","documentation":"During composer post-install (postInstall in src/Console/Installer.php), an interactive prompt asks 'Set Folder Permissions ? (Default to Y)'. The answer is validated by a closure that only accepts Y, y, N, n; any other input throws a plain Exception with this message. askAndValidate will re-prompt up to 10 times, then default to 'Y'.","triggerScenarios":"Answering the folder-permissions prompt with anything other than Y/y/N/n — e.g. 'yes', 'no', '1', empty non-default input, or pasted text with trailing whitespace; repeated invalid answers eventually exhaust retries and fall back to 'Y'.","commonSituations":"Developers habitually typing 'yes'/'no' at a Y/n prompt; non-English keyboard layouts adding stray characters; pasting answers with spaces; running composer create-project interactively in a terminal that mangles input.","solutions":["Answer exactly with a single character: Y (or y) to set permissions, N (or n) to skip.","If you want to skip, answer 'n' rather than 'no'.","To avoid the prompt entirely, install non-interactively or accept the 'Y' default by just pressing Enter.","If permissions were skipped, set them manually per CakePHP docs (chown/chmod on tmp and logs to the web server user)."],"exampleFix":"// before\nSet Folder Permissions ? (Default to Y) [Y,n]? yes\nException: This is not a valid answer. Please choose Y or n.\n// after\nSet Folder Permissions ? (Default to Y) [Y,n]? y","handlingStrategy":"validation","validationCode":"$answer = trim((string) readline('Set Folder Permissions? [Y,n] '));\nif (!in_array(strtolower($answer), ['y', 'n'], true)) {\n    fwrite(STDERR, \"Answer must be exactly Y or n.\\n\");\n}","typeGuard":null,"tryCatchPattern":"// AskAndValidate re-prompts 10 times then defaults to 'Y'; just retry:\n$setPerms = $io->askAndValidate('Set Folder Permissions? [Y,n]? ',\n    fn($a) => in_array($a, ['Y','y','N','n'], true) ? $a : throw new Exception('This is not a valid answer. Please choose Y or n.'),\n    10, 'Y');","preventionTips":["Answer single characters Y or n, never 'yes'/'no'.","Press Enter to accept the Y default when unsure.","Avoid pasting multi-character answers into the prompt.","Use non-interactive install in scripts to bypass prompts."],"tags":["cli","composer","interactive-prompt","input-validation"],"backgroundTag":"invalid-flag-value","analyzedSha":"31c1bbc10f32808a607fa9bd81891e898779c0bc","analyzedAt":"2026-09-17T00:04:38.960Z","contentChangedAt":"2026-09-17T00:04:38.960Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}