{"record":{"id":"d568dd1c297c4d08","repo":"siyuan-note/siyuan","slug":"includetime-requires-a-created-or-updated-field","errorCode":null,"errorMessage":"includeTime requires a created or updated field","messagePattern":"includeTime requires a created or updated field","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/attribute_view_key_config.go","lineNumber":97,"sourceCode":"\t\t\t\tif av.KeyTypeTemplate == key.Type {\n\t\t\t\t\treturn errors.New(\"use template for a template field\")\n\t\t\t\t}\n\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\":","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/attribute_view_key_config.go#L79-L115","documentation":"'includeTime' toggles whether created/updated timestamps record a time-of-day component, so it is only valid on fields of type 'created' or 'updated'. For any other field type UpdateAttributeViewKeyConfig returns 'includeTime requires a created or updated field'.","triggerScenarios":"Calling UpdateAttributeViewKeyConfig(avID, keyID, {\"includeTime\": true}) where key.Type is not KeyTypeCreated and not KeyTypeUpdated (e.g. a 'date', 'text', or 'number' field).","commonSituations":"A UI or script applies includeTime uniformly to all date-like fields including plain 'date' fields, assuming date and created/updated share the same options; automation written against an older schema where date fields also supported includeTime.","solutions":["Apply includeTime only to created/updated fields; for plain date fields use the date settings ('autoFillNow', 'fillSpecificTime') instead.","Check key.Type before the call and skip or redirect the setting per field type.","If a 'date' field should carry time, configure its date format ('dateFormat' setting) rather than includeTime."],"exampleFix":"// before (date field)\nUpdateAttributeViewKeyConfig(avID, dateKeyID, {\"includeTime\": true})\n// after\nUpdateAttributeViewKeyConfig(avID, createdKeyID, {\"includeTime\": true})","handlingStrategy":"validation","validationCode":"// JS: includeTime only for created/updated fields\nconst ok = key.type === \"created\" || key.type === \"updated\";\nif (!ok) throw new Error(\"includeTime requires a created or updated field\");","typeGuard":"function supportsIncludeTime(key) { return [\"created\", \"updated\"].includes(key.type); }","tryCatchPattern":"try { await updateKeyConfig(avID, keyID, { includeTime: true }); } catch (e) { if (String(e).includes(\"includeTime requires\")) { console.warn(\"skipped includeTime for\", keyID); } else { throw e; } }","preventionTips":["Map settings to allowed field types in one table and consult it before calls","Remember: date fields use autoFillNow/fillSpecificTime, created/updated use includeTime","Test config scripts against a sample database with one field of each type"],"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"}