{"record":{"id":"558101ef30ccd951","repo":"passbolt/passbolt_api","slug":"invalid-data-to-create-a-scim-operation","errorCode":null,"errorMessage":"Invalid data to create a SCIM Operation","messagePattern":"Invalid data to create a SCIM Operation","errorType":"exception","errorClass":"Cake\\Http\\Exception\\BadRequestException","httpStatus":400,"severity":"error","filePath":"plugins/PassboltEe/Scim/src/Utility/Object/Operation.php","lineNumber":118,"sourceCode":"        $this->validateScimData($data);\n        $this->setType($data['op'] ?? null);\n        $this->setPathData($data['path'] ?? null);\n        $this->value = $data['value'] ?? null;\n\n        return $this;\n    }\n\n    /**\n     * @param array $data\n     * @return void\n     */\n    protected function validateScimData(array $data): void\n    {\n        if (\n            !array_key_exists('op', $data) ||\n            !array_key_exists('value', $data)\n        ) {\n            throw new BadRequestException('Invalid data to create a SCIM Operation');\n        }\n        if (\n            !array_key_exists('path', $data) &&\n            !is_array($data['value'])\n        ) {\n            throw new BadRequestException('Invalid data to create a SCIM Operation');\n        }\n    }\n\n    /**\n     * @inheritDoc\n     */\n    public function toSCIM(): array\n    {\n        return [\n            'op' => $this->operationType,\n            'path' => $this->path,\n            'value' => $this->value,","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltEe/Scim/src/Utility/Object/Operation.php#L100-L136","documentation":"SCIM Operation objects require at least an 'op' key and a 'value' key in their raw data. When setFromScim is given operation data missing either key, validateScimData throws this BadRequestException before constructing the object. It guards against malformed PATCH operation payloads.","triggerScenarios":"Calling Operation::setFromScim() with an array lacking 'op' (e.g. ['value' => [...]]) or lacking 'value' (e.g. ['op' => 'replace', 'path' => 'active']), typically from a SCIM PATCH request Operations[] entry.","commonSituations":"A SCIM client omits 'value' for a remove operation variant passbolt doesn't accept; hand-crafted PATCH JSON misses a field; IdP sends non-standard operation objects.","solutions":["Ensure each entry in the PATCH request 'Operations' array contains both 'op' and 'value' keys.","For remove operations, include a 'value' key (even an empty array or the required value shape) as passbolt requires it.","Validate the PATCH payload against RFC 7644 section 3.5.2 before sending.","Inspect the incoming JSON and log it to identify the offending operation entry."],"exampleFix":"// before\n{\"op\": \"replace\", \"path\": \"active\"}\n// after\n{\"op\": \"replace\", \"path\": \"active\", \"value\": true}","handlingStrategy":"validation","validationCode":"// Validate each PATCH operation entry before sending\nforeach ($payload['Operations'] as $op) {\n    if (!array_key_exists('op', $op) || !array_key_exists('value', $op)) {\n        throw new InvalidArgumentException('SCIM operation must contain both op and value');\n    }\n}","typeGuard":"function isValidScimOperation(mixed $op): bool {\n    return is_array($op) && array_key_exists('op', $op) && array_key_exists('value', $op);\n}","tryCatchPattern":"try {\n    $operation = Operation::setFromScim($data);\n} catch (BadRequestException $e) {\n    // log $data and reject/repair the operation entry\n}","preventionTips":["Always emit both op and value in every Operations entry, including remove ops.","Validate PATCH payloads against RFC 7644 examples before sending.","Add a unit test for your PATCH payload builder.","Log raw request bodies for failed SCIM calls."],"tags":["scim","patch","validation"],"backgroundTag":"missing-required-argument","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"}