{"record":{"id":"beeb7d2ff36cb669","repo":"ramsey/uuid","slug":"s-argument-1-data-is-invalid-beeb7d","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/Lazy/LazyUuidFromString.php","lineNumber":111,"sourceCode":"\n    /**\n     * {@inheritDoc}\n     *\n     * @param non-empty-string $data\n     */\n    public function unserialize(string $data): void\n    {\n        $this->uuid = $data;\n    }\n\n    /**\n     * @param array{string?: non-empty-string} $data\n     */\n    public function __unserialize(array $data): void\n    {\n        // @codeCoverageIgnoreStart\n        if (!isset($data['string'])) {\n            throw new ValueError(sprintf('%s(): Argument #1 ($data) is invalid', __METHOD__));\n        }\n        // @codeCoverageIgnoreEnd\n\n        $this->unserialize($data['string']);\n    }\n\n    public function getNumberConverter(): NumberConverterInterface\n    {\n        return ($this->unwrapped ?? $this->unwrap())->getNumberConverter();\n    }\n\n    /**\n     * @inheritDoc\n     */\n    public function getFieldsHex(): array\n    {\n        return ($this->unwrapped ?? $this->unwrap())->getFieldsHex();\n    }","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/ramsey/uuid/blob/da5b521600a707d2dd097598464bd3090de850f5/src/Lazy/LazyUuidFromString.php#L93-L129","documentation":"LazyUuidFromString is the lazy wrapper Uuid::fromString() returns; PHP calls __unserialize(array $data) when restoring it via unserialize(). The serialized payload must be an array containing a 'string' key (produced by the matching __serialize). If the array lacks that key, sprintf() builds a ValueError naming the method — mirroring PHP's own internal-argument error style.","triggerScenarios":"Manually crafting an unserialize payload (e.g. unserialize('O:44:\"Ramsey\\\\Uuid\\\\Lazy\\\\LazyUuidFromString\":1:{a:0:{}}') style structures), double-serializing/wrapping the object, or feeding unserialize() a string produced by a different ramsey/uuid version or a different class that maps into this one.","commonSituations":"Cached serialized UUID objects across library upgrades; queue/session payloads hand-assembled or truncated; using var_export()/eval tricks instead of serialize(); data corrupted in storage.","solutions":["Do not build serialization payloads by hand — only unserialize() strings created by serialize() of the same class","Re-generate cached serialized UUIDs after upgrading ramsey/uuid (store the canonical string form instead)","Store Uuid objects as their 36-char string and call Uuid::fromString() on read, avoiding object serialization entirely"],"exampleFix":"// before\n$payload = ['uuid' => ['str' => '...']]; // hand-made, wrong key\n$obj = unserialize(serialize($payload['uuid']));\n\n// after\n$payload = ['uuid' => 'a3f0f0c8-0f4b-11ef-9f3f-0242ac110002'];\n$uuid = \\Ramsey\\Uuid\\Uuid::fromString($payload['uuid']);","handlingStrategy":"try-catch","validationCode":"$data = unserialize($serialized);\nif (!is_array($data) || !isset($data['string'])) {\n    throw new RuntimeException('Corrupt LazyUuidFromString payload: missing string key');\n}","typeGuard":null,"tryCatchPattern":"try {\n    $obj = unserialize($blob);\n} catch (\\ValueError $e) {\n    // payload not produced by __serialize of this class; rebuild from string form\n    $obj = \\Ramsey\\Uuid\\Uuid::fromString($knownString);\n}","preventionTips":["Never hand-craft serialization payloads; only round-trip serialize()/unserialize()","Cache UUIDs as 36-char strings, not serialized objects, to survive library upgrades","Version your cache keys by library major version"],"tags":["php","ramsey-uuid","serialization","unserialize","value-error","lazy-loading"],"backgroundTag":"unserialization-format-mismatch","analyzedSha":"da5b521600a707d2dd097598464bd3090de850f5","analyzedAt":"2026-08-21T01:35:29.252Z","schemaVersion":2},"datasetVersion":"2026-08-21T03:17:12.404Z"}