passbolt/passbolt_api · warning · Exception

This is not a valid answer. Please choose Y or n.

Error message

This is not a valid answer. Please choose Y or n.

What it means

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'.

Solutions

  1. Answer exactly with a single character: Y (or y) to set permissions, N (or n) to skip.
  2. If you want to skip, answer 'n' rather than 'no'.
  3. To avoid the prompt entirely, install non-interactively or accept the 'Y' default by just pressing Enter.
  4. If permissions were skipped, set them manually per CakePHP docs (chown/chmod on tmp and logs to the web server user).

Example fix

// before
Set Folder Permissions ? (Default to Y) [Y,n]? yes
Exception: This is not a valid answer. Please choose Y or n.
// after
Set Folder Permissions ? (Default to Y) [Y,n]? y
Defensive patterns

Strategy: validation

Validate before calling

$answer = trim((string) readline('Set Folder Permissions? [Y,n] '));
if (!in_array(strtolower($answer), ['y', 'n'], true)) {
    fwrite(STDERR, "Answer must be exactly Y or n.\n");
}

Try / catch

// AskAndValidate re-prompts 10 times then defaults to 'Y'; just retry:
$setPerms = $io->askAndValidate('Set Folder Permissions? [Y,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.'),
    10, 'Y');

Prevention

When it happens

Trigger: 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'.

Common situations: 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.

Understand the failure class

Background: "unknown output mode", "invalid value for flag", "expects true/false": fixing invalid flag value errors in CLI tools — this error's family across 24 libraries.

Related errors


AI-assisted analysis of passbolt/passbolt_api@31c1bbc10f (2026-09-17). Data as JSON: /api/errors/e53f9f6598b1850b. Report an issue: GitHub.

Appendix: source

Thrown at src/Console/Installer.php:70

     * @throws \Exception Exception raised by validator.
     * @return void
     */
    public static function postInstall(Event $event): void
    {
        $io = $event->getIO();

        $rootDir = dirname(dirname(__DIR__));

        static::createAppConfig($rootDir, $io);
        static::createWritableDirectories($rootDir, $io);

        // ask if the permissions should be changed
        if ($io->isInteractive()) {
            $validator = function ($arg) {
                if (in_array($arg, ['Y', 'y', 'N', 'n'])) {
                    return $arg;
                }
                throw new Exception('This is not a valid answer. Please choose Y or n.');
            };
            $setFolderPermissions = $io->askAndValidate(
                '<info>Set Folder Permissions ? (Default to Y)</info> [<comment>Y,n</comment>]? ',
                $validator,
                10,
                'Y'
            );

            if (in_array($setFolderPermissions, ['Y', 'y'])) {
                static::setFolderPermissions($rootDir, $io);
            }
        } else {
            static::setFolderPermissions($rootDir, $io);
        }

        static::setSecuritySalt($rootDir, $io);
    }

View on GitHub (pinned to 31c1bbc10f)