siyuan-note/siyuan · error

unsupported value type [%s]

Error message

unsupported value type [%s]

What it means

The default case in normalizeNewItemTemplateValue's type switch (kernel/av/new_item_template.go:428-429). It fires when key.Type does not match any handled case (text, number, date, select/mSelect, url, email, phone, mAsset, checkbox, relation). Non-editable types like block, template, created, updated, and rollup fall through to here. Under normal flow, isNewItemTemplateEditableKeyType filters those out before this function is reached, so this error indicates either a bypassed guard or a newly added KeyType not yet covered by the normalizer.

Source

Thrown at kernel/av/new_item_template.go:429

		value.MAsset = assets
		value.Text, value.Number, value.Date, value.MSelect, value.URL, value.Email, value.Phone, value.Checkbox, value.Relation = nil, nil, nil, nil, nil, nil, nil, nil, nil
	case KeyTypeCheckbox:
		if nil == value.Checkbox {
			return nil, errors.New("checkbox value is missing")
		}
		value.Text, value.Number, value.Date, value.MSelect, value.URL, value.Email, value.Phone, value.MAsset, value.Relation = nil, nil, nil, nil, nil, nil, nil, nil, nil
	case KeyTypeRelation:
		if nil == value.Relation {
			return nil, errors.New("relation value is missing")
		}
		for _, blockID := range value.Relation.BlockIDs {
			if !ast.IsNodeIDPattern(blockID) {
				return nil, fmt.Errorf("invalid relation block ID [%s]", blockID)
			}
		}
		value.Text, value.Number, value.Date, value.MSelect, value.URL, value.Email, value.Phone, value.MAsset, value.Checkbox = nil, nil, nil, nil, nil, nil, nil, nil, nil
	default:
		return nil, fmt.Errorf("unsupported value type [%s]", key.Type)
	}
	value.Block, value.Template, value.Created, value.Updated, value.Rollup = nil, nil, nil, nil, nil
	value.ID = ""
	value.KeyID = ""
	value.BlockID = ""
	value.Type = key.Type
	value.IsDetached = false
	value.CreatedAt = 0
	value.UpdatedAt = 0
	value.IsRenderAutoFill = false
	if nil != value.Number {
		value.Number.Format = key.NumberFormat
		value.Number.FormattedContent = ""
	}
	if nil != value.Date {
		value.Date.FormattedContent = ""
	}
	if nil != value.Created {

View on GitHub (pinned to 251596fc0d)

Solutions

  1. Do not include non-editable field types (block, template, created, updated, rollup) in new-item template FieldValues
  2. If you added a new KeyType, add a corresponding case to the type switch in normalizeNewItemTemplateValue
  3. Remove the offending field from the template and retry

Example fix

// before: template includes a created-type key
itemTemplate.FieldValues[createdKeyID] = &av.NewItemFieldValue{Mode: av.NewItemFieldValueStatic, Value: &av.Value{Type: av.KeyTypeCreated}}
// after: omit non-editable keys from templates
delete(itemTemplate.FieldValues, createdKeyID)
Defensive patterns

Strategy: validation

Validate before calling

func isNormalizableKeyType(keyType av.KeyType) bool {
    switch keyType {
    case av.KeyTypeText, av.KeyTypeNumber, av.KeyTypeDate,
        av.KeyTypeSelect, av.KeyTypeMSelect, av.KeyTypeURL,
        av.KeyTypeEmail, av.KeyTypePhone, av.KeyTypeMAsset,
        av.KeyTypeCheckbox, av.KeyTypeRelation:
        return true
    }
    return false
}

func validateTemplateKeyType(key *av.Key) error {
    if !isNormalizableKeyType(key.Type) {
        return fmt.Errorf("key type %q is not supported in new-item templates", key.Type)
    }
    return nil
}

Type guard

func isTemplateEditableKeyType(t av.KeyType) bool {
    // Block, Template, Created, Updated, Rollup are non-editable in templates
    switch t {
    case av.KeyTypeBlock, av.KeyTypeTemplate, av.KeyTypeCreated, av.KeyTypeUpdated, av.KeyTypeRollup:
        return false
    }
    return true
}

Prevention

When it happens

Trigger: A new-item template FieldValues entry references a key whose type is one of the non-normalizable types (block, template, created, updated, rollup), or a custom/unknown key type string.

Common situations: Adding a new KeyType constant to the av package without updating normalizeNewItemTemplateValue's switch; directly calling normalizeNewItemTemplateValue bypassing the editable-key-type filter; corrupted AV data with an unexpected type string.

Related errors


AI-assisted analysis of siyuan-note/siyuan@251596fc0d (2026-08-12). Data as JSON: /api/errors/fb155afdcb20505e. Report an issue: GitHub.