{"record":{"id":"09c7c049b6b6ba72","repo":"passbolt/passbolt_api","slug":"few-fields-are-missing-for-the-v5","errorCode":null,"errorMessage":"Few fields are missing for the V5.","messagePattern":"Few fields are missing for the V5\\.","errorType":"validation","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"plugins/PassboltCe/Metadata/src/Model/Dto/MetadataFolderDto.php","lineNumber":170,"sourceCode":"                $isV4 = false;\n            } else {\n                $v5MissingFields[] = $metadataField;\n            }\n        }\n        if ($isV4) {\n            return;\n        }\n\n        // Now that we know that we are in v5, we check that all the v5 metadata fields are set\n        // If all v5 fields are not provided, throw an exception.\n        if (!empty($v5MissingFields)) {\n            $msg = __('Few fields are missing for the V5.');\n            if (Configure::read('debug')) {\n                Log::error($msg);\n                Log::error(__('Missing fields: {0}', implode(', ', $v5MissingFields)));\n            }\n\n            throw new BadRequestException($msg);\n        }\n\n        // Now that we know that we have a valid v5 payload, we check that no v4 fields are in the payload\n        $v4SuperfluousFields = [];\n        foreach (self::V4_META_PROPS as $v4Field) {\n            if (array_key_exists($v4Field, $data) && !is_null($data[$v4Field])) {\n                $v4SuperfluousFields[] = $v4Field;\n            }\n        }\n        if (!empty($v4SuperfluousFields)) {\n            $msg = __('V4 related fields are not supported for V5.');\n            if (Configure::read('debug')) {\n                Log::error($msg);\n                Log::error(__('Superfluous fields: {0}', implode(', ', $v4SuperfluousFields)));\n            }\n\n            throw new BadRequestException($msg);\n        }","sourceCodeStart":152,"sourceCodeEnd":188,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltCe/Metadata/src/Model/Dto/MetadataFolderDto.php#L152-L188","documentation":"MetadataFolderDto validates that a v5 folder payload contains all required v5 metadata properties (object_type, id, parent_id, name, etc.). If any are missing, it logs details when debug is on and throws this 400 BadRequestException.","triggerScenarios":"Folder create/update with v5 metadata missing one or more required props (e.g. no 'object_type', missing 'folder_parent_id'/'name' fields in the encrypted metadata JSON).","commonSituations":"Clients migrating from v4 payloads and dropping required v5 fields; hand-rolled encryption code producing incomplete metadata JSON; schema drift between client and server versions.","solutions":["Add all required V5_META_PROPS fields to the folder metadata payload before sending.","Update the client/passbolt library version so metadata generation matches the server schema.","Enable debug to read the logged 'Missing fields' list and fix exactly those keys.","Ensure the metadata JSON is decrypted/parsed correctly and not truncated."],"exampleFix":"// before\nmetadata = JSON.stringify({object_type: 'FOLDER', name}); // missing id, parent_id...\n// after\nmetadata = JSON.stringify({object_type: 'FOLDER', id: folderUuid, parent_parent_id: parentId, name, created, modified, created_by, modified_by});","handlingStrategy":"validation","validationCode":"const V5_META_PROPS = ['object_type','id','parent_id','name','created','modified','created_by','modified_by'];\nconst missing = V5_META_PROPS.filter(p => meta[p] === undefined || meta[p] === null);\nif (missing.length) throw new Error('v5 metadata missing: ' + missing.join(', '));","typeGuard":"const hasAllV5Props = (m) => V5_META_PROPS.every(p => m?.[p] != null);","tryCatchPattern":"try { await api.post('/folders', payload); } catch (e) { if (e.response?.status === 400 && String(e.message).includes('Few fields are missing for the V5')) { console.error('rebuild metadata for folder', folderId); return rebuildAndRetry(); } throw e; }","preventionTips":["Build v5 metadata via the shared schema/validation helpers, not ad-hoc objects.","Keep client and server metadata schema versions in sync.","Validate decrypted metadata JSON against the v5 schema before upload.","Run with debug enabled during development to see missing-field logs."],"tags":["metadata","validation","v5","folders"],"backgroundTag":"schema-validation-failed","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"}