{"record":{"id":"08a256295b7fbf68","repo":"Seldaek/monolog","slug":"sqshandler-accepts-only-formatted-records-as-a-str","errorCode":null,"errorMessage":"SqsHandler accepts only formatted records as a string","messagePattern":"SqsHandler accepts only formatted records as a string","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"src/Monolog/Handler/SqsHandler.php","lineNumber":48,"sourceCode":"\n    private SqsClient $client;\n    private string $queueUrl;\n\n    public function __construct(SqsClient $sqsClient, string $queueUrl, int|string|Level $level = Level::Debug, bool $bubble = true)\n    {\n        parent::__construct($level, $bubble);\n\n        $this->client = $sqsClient;\n        $this->queueUrl = $queueUrl;\n    }\n\n    /**\n     * @inheritDoc\n     */\n    protected function write(LogRecord $record): void\n    {\n        if (!isset($record->formatted) || 'string' !== \\gettype($record->formatted)) {\n            throw new \\InvalidArgumentException('SqsHandler accepts only formatted records as a string' . Utils::getRecordMessageForException($record));\n        }\n\n        $messageBody = $record->formatted;\n        if (\\strlen($messageBody) >= static::MAX_MESSAGE_SIZE) {\n            $messageBody = Utils::substr($messageBody, 0, static::HEAD_MESSAGE_SIZE);\n        }\n\n        $this->client->sendMessage([\n            'QueueUrl' => $this->queueUrl,\n            'MessageBody' => $messageBody,\n        ]);\n    }\n}\n","sourceCodeStart":30,"sourceCodeEnd":62,"githubUrl":"https://github.com/Seldaek/monolog/blob/57eb1028342134e701e77c617565d51b6e5a2a53/src/Monolog/Handler/SqsHandler.php#L30-L62","documentation":"Error \"SqsHandler accepts only formatted records as a string\" thrown in Seldaek/monolog.","triggerScenarios":"Thrown at src/Monolog/Handler/SqsHandler.php:48 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"57eb1028342134e701e77c617565d51b6e5a2a53","analyzedAt":"2026-08-17T02:36:30.259Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}