siyuan-note/siyuan · error

numberFormat requires a number field and a supported format

Error message

numberFormat requires a number field and a supported format

What it means

The "numberFormat" setting only applies to fields whose type is KeyTypeNumber, and the value must be one of the supported formats listed in AttributeViewKeyNumberFormats. Applying it to a non-number field, or using an unsupported format string, is rejected.

Solutions

  1. Change the field type to "number" first, then apply numberFormat in a second call
  2. Use a format string from AttributeViewKeyNumberFormats exactly (e.g. "2", "10000.00")
  3. Check key.Type == number before sending numberFormat from client code

Example fix

// before
updateKeyConfig(avID, textKeyID, {"numberFormat": "2"})
// after
updateKeyConfig(avID, numberKeyID, {"numberFormat": "2"})
Defensive patterns

Strategy: validation

Validate before calling

const NUMBER_FORMATS = ['','2','10000','10000.0','10000.00','0.1%','0.10%','0.12%','10000.00W','1.00E+03','2000-01-01','2000-01'];
function assertNumberFormat(key, fmt) { if (key.type !== 'number') throw new Error('numberFormat requires a number field'); if (!NUMBER_FORMATS.includes(fmt)) throw new Error('unsupported format'); }

Type guard

const isNumberField = (key) => key?.type === 'number';

Try / catch

try { await updateKeyConfig(avID, keyID, { numberFormat: fmt }); } catch (e) { if (/numberFormat requires/.test(e.message)) { await updateKeyConfig(avID, keyID, { type: 'number' }); return updateKeyConfig(avID, keyID, { numberFormat: fmt }); } throw e; }

Prevention

When it happens

Trigger: Calling UpdateAttributeViewKeyConfig with {"numberFormat": "2"} on a text/date/template field, or with a typo'd/unknown format such as {"numberFormat": "percent"}.

Common situations: Scripts applying number formatting to columns of unknown type; format names guessed instead of taken from the supported list; a field whose type was changed after the format was chosen.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19). Data as JSON: /api/errors/27a34ab70a6c2c5b. Report an issue: GitHub.

Appendix: source

Thrown at kernel/model/attribute_view_key_config.go:68

			case "name":
				if "" == strings.TrimSpace(text) {
					return errors.New("field name must not be empty")
				}
				op.Name = text
				return updateAttributeViewColumn(op)
			case "type":
				if _, err = newAttributeViewKey(keyID, key.Name, text, key.Icon, key.DateFormat); nil != err {
					return err
				}
				op.Typ = text
				return updateAttributeViewColumn(op)
			case "icon":
				return setAttributeViewColIcon(op)
			case "desc":
				return setAttributeViewColDesc(op)
			case "numberFormat":
				if av.KeyTypeNumber != key.Type || !slices.Contains(AttributeViewKeyNumberFormats, text) {
					return errors.New("numberFormat requires a number field and a supported format")
				}
				return updateAttributeViewColNumberFormat(op)
			case "dateFormat":
				return setAttributeViewColDateFormat(op)
			case "template":
				if av.KeyTypeTemplate != key.Type {
					return errors.New("template requires a template field; use renderTemplate for other fields")
				}
				return updateAttributeViewColTemplate(op)
			case "renderTemplate":
				if av.KeyTypeTemplate == key.Type {
					return errors.New("use template for a template field")
				}
				return updateAttributeViewColTemplate(op)
			}
		case "autoFillNow", "fillSpecificTime", "includeTime":
			flag, ok := value.(bool)
			if !ok {

View on GitHub (pinned to 9f775e8a12)