{"record":{"id":"c8d2150fa2725ba2","repo":"siyuan-note/siyuan","slug":"s-requires-a-date-field","errorCode":null,"errorMessage":"%s requires a date field","messagePattern":"(.+?) requires a date field","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/attribute_view_key_config.go","lineNumber":100,"sourceCode":"\t\t\t\treturn updateAttributeViewColTemplate(op)\n\t\t\t}\n\t\tcase \"autoFillNow\", \"fillSpecificTime\", \"includeTime\":\n\t\t\tflag, ok := value.(bool)\n\t\t\tif !ok {\n\t\t\t\treturn fmt.Errorf(\"%s must be a boolean\", setting)\n\t\t\t}\n\t\t\top.Data = flag\n\t\t\tif \"includeTime\" == setting {\n\t\t\t\tswitch key.Type {\n\t\t\t\tcase av.KeyTypeCreated:\n\t\t\t\t\treturn setAttrViewCreatedIncludeTime(op)\n\t\t\t\tcase av.KeyTypeUpdated:\n\t\t\t\t\treturn setAttrViewUpdatedIncludeTime(op)\n\t\t\t\t}\n\t\t\t\treturn errors.New(\"includeTime requires a created or updated field\")\n\t\t\t}\n\t\t\tif av.KeyTypeDate != key.Type {\n\t\t\t\treturn fmt.Errorf(\"%s requires a date field\", setting)\n\t\t\t}\n\t\t\tif \"autoFillNow\" == setting {\n\t\t\t\treturn setAttributeViewColDateFillCreated(op)\n\t\t\t}\n\t\t\treturn setAttrViewColDateFillSpecificTime(op)\n\t\tcase \"options\", \"optionUpdate\", \"optionRemove\":\n\t\t\tif av.KeyTypeSelect != key.Type && av.KeyTypeMSelect != key.Type {\n\t\t\t\treturn errors.New(\"option settings require a select or mSelect field\")\n\t\t\t}\n\t\t\treturn updateAttributeViewKeyOptions(attrView, key, op, setting, value)\n\t\tcase \"relation\":\n\t\t\treturn updateAttributeViewKeyRelation(key, op, value)\n\t\tcase \"rollup\":\n\t\t\treturn updateAttributeViewKeyRollup(attrView, key, op, value)\n\t\tcase \"relationFilters\", \"rollupFilters\":\n\t\t\tfilters, ok := value.([]any)\n\t\t\tif !ok {\n\t\t\t\treturn errors.New(\"filters must be an array\")","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/attribute_view_key_config.go#L82-L118","documentation":"The settings 'autoFillNow' (fill with current time on row creation) and 'fillSpecificTime' (fill a specific time) only apply to fields of type 'date'. For non-date fields, UpdateAttributeViewKeyConfig returns '<setting> requires a date field' naming the attempted setting.","triggerScenarios":"Calling UpdateAttributeViewKeyConfig with {\"autoFillNow\": true} or {\"fillSpecificTime\": true} where key.Type != av.KeyTypeDate (e.g. a text, number, or created/updated field).","commonSituations":"Bulk field-config scripts apply the date fill options to every field; a caller confuses 'created'/'updated' fields (which use includeTime) with 'date' fields (which use autoFillNow/fillSpecificTime).","solutions":["Target a field whose type is 'date' for autoFillNow/fillSpecificTime.","Verify key.Type via the attribute view API before sending the setting.","For created/updated fields use 'includeTime' instead of autoFillNow/fillSpecificTime."],"exampleFix":"// before (text field)\nUpdateAttributeViewKeyConfig(avID, textKeyID, {\"autoFillNow\": true})\n// after\nUpdateAttributeViewKeyConfig(avID, dateKeyID, {\"autoFillNow\": true})","handlingStrategy":"validation","validationCode":"// JS: autoFillNow/fillSpecificTime only for date fields\nif (setting !== \"includeTime\" && key.type !== \"date\") throw new Error(setting + \" requires a date field\");","typeGuard":"function isDateField(key) { return key && key.type === \"date\"; }","tryCatchPattern":"try { await updateKeyConfig(avID, keyID, { [setting]: true }); } catch (e) { if (String(e).includes(\"requires a date field\")) { console.warn(\"skipped\", setting, \"for\", keyID); } else { throw e; } }","preventionTips":["Gate autoFillNow/fillSpecificTime behind a key.type === \"date\" check","Do not reuse date-field settings for created/updated fields","Keep field-type metadata in sync after type changes"],"tags":["attribute-view","field-type","validation"],"backgroundTag":"incompatible-source-type","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}