{"record":{"id":"5ce006236a8a3974","repo":"siyuan-note/siyuan","slug":"s-must-be-a-boolean","errorCode":null,"errorMessage":"%s must be a boolean","messagePattern":"(.+?) must be a boolean","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/attribute_view_key_config.go","lineNumber":87,"sourceCode":"\t\t\t\t}\n\t\t\t\treturn updateAttributeViewColNumberFormat(op)\n\t\t\tcase \"dateFormat\":\n\t\t\t\treturn setAttributeViewColDateFormat(op)\n\t\t\tcase \"template\":\n\t\t\t\tif av.KeyTypeTemplate != key.Type {\n\t\t\t\t\treturn errors.New(\"template requires a template field; use renderTemplate for other fields\")\n\t\t\t\t}\n\t\t\t\treturn updateAttributeViewColTemplate(op)\n\t\t\tcase \"renderTemplate\":\n\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)","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/attribute_view_key_config.go#L69-L105","documentation":"The settings 'autoFillNow', 'fillSpecificTime', and 'includeTime' toggle boolean flags on date-family fields. UpdateAttributeViewKeyConfig type-asserts the config value to bool; a non-boolean value (string \"true\", number, nil) fails the assertion and produces '<setting> must be a boolean'.","triggerScenarios":"Calling UpdateAttributeViewKeyConfig with {\"autoFillNow\": \"true\"}, {\"includeTime\": 1}, {\"fillSpecificTime\": nil}, or any JSON value that is not a JSON boolean for one of these three settings.","commonSituations":"Clients built from JS habits send the string \"true\"/\"false\" or 0/1 instead of true/false in the JSON body; a template-generated payload interpolates the flag as text.","solutions":["Send a real boolean: {\"autoFillNow\": true} not {\"autoFillNow\": \"true\"}.","In JavaScript, coerce with Boolean(value) or '===' checks before building the config map.","If the source is user input, parse it (e.g. value === \"true\") before passing it as the config value."],"exampleFix":"// before\n{\"autoFillNow\": \"true\"}\n// after\n{\"autoFillNow\": true}","handlingStrategy":"type-guard","validationCode":"// JS: ensure boolean before sending\nif (typeof flag !== \"boolean\") throw new TypeError(setting + \" must be a boolean\");","typeGuard":"function isBool(v) { return typeof v === \"boolean\"; }","tryCatchPattern":"try { await updateKeyConfig(avID, keyID, { [setting]: flag }); } catch (e) { if (String(e).includes(\"must be a boolean\")) { throw new TypeError(\"Fix payload: \" + setting + \" must be true/false, got \" + typeof flag); } throw e; }","preventionTips":["Use JSON booleans, never \"true\"/\"false\" strings or 0/1","Add a schema (e.g. zod/ajv) check for config payloads","Coerce user input with strict === \"true\" checks, not truthiness"],"tags":["type-mismatch","boolean","attribute-view"],"backgroundTag":"type-mismatch","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"}