{"record":{"id":"94480df52535ecbf","repo":"siyuan-note/siyuan","slug":"option-settings-require-a-select-or-mselect-field","errorCode":null,"errorMessage":"option settings require a select or mSelect field","messagePattern":"option settings require a select or mSelect field","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/attribute_view_key_config.go","lineNumber":108,"sourceCode":"\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\")\n\t\t\t}\n\t\t\tif err = validateAttributeViewKeyFilters(attrView, key, setting, filters); nil != err {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\treturn setAttrViewColFilters(avID, \"\", keyID, filters, \"relationFilters\" == setting)\n\t\tdefault:\n\t\t\treturn fmt.Errorf(\"unknown field setting: %s\", setting)\n\t\t}","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/attribute_view_key_config.go#L90-L126","documentation":"The option-management settings 'options' (replace), 'optionUpdate', and 'optionRemove' operate on select-type option lists, so they are valid only on fields of type 'select' or 'mSelect'. UpdateAttributeViewKeyConfig rejects them for any other field type with 'option settings require a select or mSelect field'.","triggerScenarios":"Calling UpdateAttributeViewKeyConfig with any of {\"options\": [...]}, {\"optionUpdate\": ...}, or {\"optionRemove\": ...} where key.Type is neither KeyTypeSelect nor KeyTypeMSelect.","commonSituations":"A sync/import script rewrites option lists across all select-like fields but includes single-select-in-spirit fields that are actually of another type; the field's type was changed away from select while the client kept applying option updates.","solutions":["Change the field type to 'select' or 'mSelect' via the 'type' setting before managing options.","Check key.Type before the call and skip option settings for non-select fields.","Verify the keyID points at the intended select field (IDs can be mixed up when iterating fields)."],"exampleFix":"// before\nUpdateAttributeViewKeyConfig(avID, textFieldID, {\"optionRemove\": \"old\"})\n// after\nUpdateAttributeViewKeyConfig(avID, selectFieldID, {\"optionRemove\": \"old\"})","handlingStrategy":"validation","validationCode":"// JS: option settings only for select/mSelect fields\nif (![\"select\", \"mSelect\"].includes(key.type)) throw new Error(\"option settings require a select or mSelect field\");","typeGuard":"function isSelectLike(key) { return key && (key.type === \"select\" || key.type === \"mSelect\"); }","tryCatchPattern":"try { await updateKeyConfig(avID, keyID, { options: newOptions }); } catch (e) { if (String(e).includes(\"select or mSelect\")) { throw new Error(\"Field \" + keyID + \" is not a select field; change type first\"); } throw e; }","preventionTips":["Verify keyID resolves to a select/mSelect field before option operations","Change field type to select first if option management is required","When iterating fields in bulk, filter by type before applying option settings"],"tags":["attribute-view","field-type","select-options"],"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"}