{"record":{"id":"c52788628877ae64","repo":"ramsey/uuid","slug":"s-argument-1-data-is-invalid-c52788","errorCode":null,"errorMessage":"%s(): Argument #1 ($data) is invalid","messagePattern":"(.+?)\\(\\): Argument #1 \\(\\$data\\) is invalid","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/Type/Time.php","lineNumber":123,"sourceCode":"    {\n        /** @var array{seconds?: float | int | string, microseconds?: float | int | string} $time */\n        $time = json_decode($data, true);\n\n        if (!isset($time['seconds']) || !isset($time['microseconds'])) {\n            throw new UnsupportedOperationException('Attempted to unserialize an invalid value');\n        }\n\n        $this->__construct($time['seconds'], $time['microseconds']);\n    }\n\n    /**\n     * @param array{seconds?: string, microseconds?: string} $data\n     */\n    public function __unserialize(array $data): void\n    {\n        // @codeCoverageIgnoreStart\n        if (!isset($data['seconds']) || !isset($data['microseconds'])) {\n            throw new ValueError(sprintf('%s(): Argument #1 ($data) is invalid', __METHOD__));\n        }\n        // @codeCoverageIgnoreEnd\n\n        $this->__construct($data['seconds'], $data['microseconds']);\n    }\n}\n","sourceCodeStart":105,"sourceCodeEnd":130,"githubUrl":"https://github.com/ramsey/uuid/blob/da5b521600a707d2dd097598464bd3090de850f5/src/Type/Time.php#L105-L130","documentation":"When PHP unserializes a Ramsey\\Uuid\\Type\\Time object via the modern __unserialize(array $data) path, the array must contain both 'seconds' and 'microseconds' keys. A missing key throws a native ValueError whose message mirrors PHP's internal argument errors. The payload did not come from this class's __serialize() output, or it was corrupted.","triggerScenarios":"unserialize() of a Time payload whose array body lacks 'seconds' or 'microseconds' — hand-edited serialized strings, cache values from a differently-shaped producer, or payloads damaged in storage.","commonSituations":"Serialized blobs in Redis/sessions shared across application versions; cross-service payload exchange with mismatched expectations; corrupted data after partial writes or crashes.","solutions":["Rebuild the object: new Time($seconds, $microseconds)","Invalidate the malformed cache/queue entries so they are rewritten","Pin compatible library versions on all sides that share the store","Serialize primitives (two ints/strings) rather than the object itself"],"exampleFix":"// before\n$time = unserialize($cachedValue); // array body missing 'seconds'/'microseconds'\n// ValueError: Ramsey\\Uuid\\Type\\Time::__unserialize(): Argument #1 ($data) is invalid\n\n// after: persist parts and reconstruct\n$time = new Time($seconds, $microseconds);","handlingStrategy":"try-catch","validationCode":"// Validate shape before trusting a stored payload\n$decoded = unserialize($cached, ['allowed_classes' => false]);\nif (!(is_array($decoded) && isset($decoded['seconds'], $decoded['microseconds']))) {\n    // treat as cache miss; rebuild\n    $time = new Ramsey\\Uuid\\Type\\Time($seconds, $microseconds);\n}","typeGuard":null,"tryCatchPattern":"use Ramsey\\Uuid\\Type\\Time;\n\ntry {\n    $time = unserialize($cached);\n} catch (\\ValueError $e) {\n    $time = new Time($seconds, $microseconds); // rebuild path\n}","preventionTips":["Serialize the two numeric components, not the object","Version keys on shared caches so shape changes invalidate cleanly","Align library versions between payload writers and readers","Always pair unserialize() of stored objects with a ValueError catch and rebuild"],"tags":["php","ramsey-uuid","time","unserialize","value-error","cache-corruption"],"backgroundTag":"unserialize-payload-invalid","analyzedSha":"da5b521600a707d2dd097598464bd3090de850f5","analyzedAt":"2026-08-21T01:35:29.252Z","schemaVersion":2},"datasetVersion":"2026-08-21T03:17:12.404Z"}