{"record":{"id":"e2572b248a7f6e39","repo":"passbolt/passbolt_api","slug":"unknown-key-validation-rule-0","errorCode":null,"errorMessage":"Unknown key validation rule: {0}","messagePattern":"Unknown key validation rule: (.+?)","errorType":"http","errorClass":"InternalErrorException","httpStatus":500,"severity":"error","filePath":"src/Service/OpenPGP/MessageValidationService.php","lineNumber":130,"sourceCode":"                    }\n                    break;\n                case self::HAS_ASYMMETRIC_PACKET_RULE:\n                    if (!$messageInfo['asymmetric']) {\n                        $validationErrors[$ruleName] = __('The message must contain an asymmetric packet.');\n                    }\n                    break;\n                case self::HAS_SYMMETRIC_PACKET_RULE:\n                    if (!$messageInfo['symmetric']) {\n                        $validationErrors[$ruleName] = __('The message must contain a symmetric packet.');\n                    }\n                    break;\n                case self::HAS_EXACTLY_ONE_RECIPIENT:\n                    if (count($messageInfo['recipients']) !== 1) {\n                        $validationErrors[$ruleName] = __('The message must contain only one recipient.');\n                    }\n                    break;\n                default:\n                    throw new InternalErrorException(__('Unknown key validation rule: {0}', $ruleName));\n            }\n        }\n\n        // Wrap all errors together in a custom validation exception\n        if (count($validationErrors)) {\n            $debug = 'The armored message could not be validated' . \"\\n\";\n            $debug .= $armoredMessage . \"\\n\" . json_encode($validationErrors);\n            Log::error($debug);\n            throw new CustomValidationException(__('The armored message could not be validated.'), [\n                'data' => $validationErrors,\n            ]);\n        }\n\n        return $messageInfo;\n    }\n\n    /**\n     * Get Message Info","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/src/Service/OpenPGP/MessageValidationService.php#L112-L148","documentation":"parseAndValidateMessage iterates the configured rule list; when it encounters a rule name it does not recognize in its switch statement, it throws InternalErrorException 'Unknown key validation rule: {0}'. This indicates a programming/config error: someone supplied a rule name outside the supported set (IS_PARSABLE_ARMORED_MESSAGE_RULE, HAS_KEY_ID, HAS_EXACTLY_ONE_RECIPIENT, etc.).","triggerScenarios":"Calling parseAndValidateMessage with a custom $rules array containing a typo or an unsupported rule key (e.g. 'has_recipient' instead of the class constants).","commonSituations":"Plugin/integration code constructing custom rule lists, refactors renaming rule constants, copy-pasted rule names from documentation of a different version.","solutions":["Use the class constants (MessageValidationService::HAS_KEY_ID, ::HAS_EXACTLY_ONE_RECIPEIENT-style names as defined in MessageValidationService) instead of string literals.","Grep your codebase for custom rule arrays and compare against the switch cases in MessageValidationService::parseAndValidateMessage.","Update integration code after passbolt version upgrades if rule names changed.","Default to getDefaultRules() when custom rules are not strictly needed."],"exampleFix":"// before\n$rules = ['has_key_id' => true];\n// after\n$rules = [MessageValidationService::HAS_KEY_ID];","handlingStrategy":"validation","validationCode":"$known = [IS_PARSABLE_ARMORED_MESSAGE_RULE, HAS_KEY_ID, HAS_EXACTLY_ONE_RECIPIENT];\nif (array_diff($rules, $known)) { throw new LogicException('unknown rule'); }","typeGuard":null,"tryCatchPattern":"try { parseAndValidateMessage($msg, $rules); } catch (InternalErrorException $e) { /* fix rule names */ }","preventionTips":["Always use class constants for rule names","Re-check rule names after upgrades","Prefer getDefaultRules()"],"tags":["openpgp","validation","internal"],"backgroundTag":"invalid-enum-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"}