{"record":{"id":"4eddaf5fcc954cf1","repo":"medusajs/medusa","slug":"defaultvalue-property-is-missing-at-the-j-ind","errorCode":null,"errorMessage":"'defaultValue' property is missing at the ${j} index of the 'forms' property in ${file}.","messagePattern":"'defaultValue' property is missing at the (.+?) index of the 'forms' property in (.+?)\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/admin/admin-vite-plugin/src/custom-fields/generate-custom-field-forms.ts","lineNumber":628,"sourceCode":"      ) {\n        logger.warn(\n          `'${name}' property in the 'fields' property at the ${j} index of the 'forms' property in ${file} is malformed. The property must be an object or a call to form.define().`,\n          { file }\n        )\n        return\n      }\n\n      const fieldObject = isObjectExpression(field.value)\n        ? field.value\n        : (field.value.arguments[0] as ObjectExpression)\n\n      const defaultValueProperty = fieldObject.properties.find(\n        (p) =>\n          isObjectProperty(p) && isIdentifier(p.key, { name: \"defaultValue\" })\n      ) as ObjectProperty | undefined\n\n      if (!defaultValueProperty) {\n        logger.warn(\n          `'defaultValue' property is missing at the ${j} index of the 'forms' property in ${file}.`,\n          { file }\n        )\n        return\n      }\n\n      const validationProperty = fieldObject.properties.find(\n        (p) =>\n          isObjectProperty(p) && isIdentifier(p.key, { name: \"validation\" })\n      ) as ObjectProperty | undefined\n\n      if (!validationProperty) {\n        logger.warn(\n          `'validation' property is missing at the ${j} index of the 'forms' property in ${file}.`,\n          { file }\n        )\n        return\n      }","sourceCodeStart":610,"sourceCodeEnd":646,"githubUrl":"https://github.com/medusajs/medusa/blob/5e06e544a296b9033f20f71f11c559f81a0e5739/packages/admin/admin-vite-plugin/src/custom-fields/generate-custom-field-forms.ts#L610-L646","documentation":"Field configs (unlike form components) require a 'defaultValue' property so the admin can initialize the field. When a field object inside 'fields' lacks defaultValue, the plugin warns with the entry index and file, then skips that entry.","triggerScenarios":"fields: { myField: { validation: ... } } where the object has validation but no defaultValue key.","commonSituations":"Assuming defaultValue is optional, porting form.define component configs (which don't need it) into the config flow, or forgetting the key when hand-writing configs.","solutions":["Add defaultValue to the field object, e.g. defaultValue: '' or defaultValue: null","Give every field in 'fields' both defaultValue and validation","Use form.define({ defaultValue, validation }) for clarity"],"exampleFix":"// before\nfields: { myField: { validation: (v) => v.length > 2 } }\n// after\nfields: { myField: { defaultValue: '', validation: (v) => v.length > 2 } }","handlingStrategy":"validation","validationCode":"Object.entries(f.fields).forEach(([name, def]) => {\n  if (typeof def !== 'object' || !('defaultValue' in def)) {\n    throw new Error(`field '${name}' is missing defaultValue`)\n  }\n})","typeGuard":"const hasDefaultValue = (d: unknown): d is { defaultValue: unknown } =>\n  typeof d === 'object' && d !== null && 'defaultValue' in (d as object)","tryCatchPattern":null,"preventionTips":["Always write defaultValue and validation together for every field config"],"tags":["admin","custom-fields","default-value","config-validation"],"backgroundTag":"admin-custom-field-form-validation","analyzedSha":"5e06e544a296b9033f20f71f11c559f81a0e5739","analyzedAt":"2026-08-27T07:24:39.599Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}