{"record":{"id":"4e78abba0d837ec6","repo":"siyuan-note/siyuan","slug":"invalid-asset-type-s","errorCode":null,"errorMessage":"invalid asset type [%s]","messagePattern":"invalid asset type \\[(.+?)\\]","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/av/new_item_template.go","lineNumber":406,"sourceCode":"\t\t\treturn nil, errors.New(\"URL value is missing\")\n\t\t}\n\t\tvalue.Text, value.Number, value.Date, value.MSelect, value.Email, value.Phone, value.MAsset, value.Checkbox, value.Relation = nil, nil, nil, nil, nil, nil, nil, nil, nil\n\tcase KeyTypeEmail:\n\t\tif nil == value.Email {\n\t\t\treturn nil, errors.New(\"email value is missing\")\n\t\t}\n\t\tvalue.Text, value.Number, value.Date, value.MSelect, value.URL, value.Phone, value.MAsset, value.Checkbox, value.Relation = nil, nil, nil, nil, nil, nil, nil, nil, nil\n\tcase KeyTypePhone:\n\t\tif nil == value.Phone {\n\t\t\treturn nil, errors.New(\"phone value is missing\")\n\t\t}\n\t\tvalue.Text, value.Number, value.Date, value.MSelect, value.URL, value.Email, value.MAsset, value.Checkbox, value.Relation = nil, nil, nil, nil, nil, nil, nil, nil, nil\n\tcase KeyTypeMAsset:\n\t\tvar assets []*ValueAsset\n\t\tfor _, asset := range value.MAsset {\n\t\t\tif nil != asset && \"\" != strings.TrimSpace(asset.Content) {\n\t\t\t\tif AssetTypeFile != asset.Type && AssetTypeImage != asset.Type {\n\t\t\t\t\treturn nil, fmt.Errorf(\"invalid asset type [%s]\", asset.Type)\n\t\t\t\t}\n\t\t\t\tassets = append(assets, asset)\n\t\t\t}\n\t\t}\n\t\tvalue.MAsset = assets\n\t\tvalue.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\n\tcase KeyTypeCheckbox:\n\t\tif nil == value.Checkbox {\n\t\t\treturn nil, errors.New(\"checkbox value is missing\")\n\t\t}\n\t\tvalue.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\n\tcase KeyTypeRelation:\n\t\tif nil == value.Relation {\n\t\t\treturn nil, errors.New(\"relation value is missing\")\n\t\t}\n\t\tfor _, blockID := range value.Relation.BlockIDs {\n\t\t\tif !ast.IsNodeIDPattern(blockID) {\n\t\t\t\treturn nil, fmt.Errorf(\"invalid relation block ID [%s]\", blockID)","sourceCodeStart":388,"sourceCodeEnd":424,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/av/new_item_template.go#L388-L424","documentation":"Thrown inside normalizeNewItemTemplateValue (kernel/av/new_item_template.go:405-406) during the KeyTypeMAsset branch. After filtering out nil/empty assets, each remaining asset's Type field is checked against exactly two constants: AssetTypeFile (\"file\") and AssetTypeImage (\"image\"). Any other type string triggers this formatted error. This is the only content-validating check in the MAsset branch; nil MAsset slices are tolerated (they just produce an empty assets slice).","triggerScenarios":"An mAsset-type template field value contains a ValueAsset whose Type is neither \"file\" nor \"image\" — for example \"link\", \"video\", \"audio\", or a typo like \"File\".","commonSituations":"Third-party tooling that generates AV values with non-standard asset types; manual JSON editing that guesses the type enum incorrectly; copy-pasting asset values from a different data model.","solutions":["Set every asset.Type to exactly \"file\" or \"image\" (lowercase ASCII)","Remove assets with unrecognized types from the MAsset slice before submitting","Check kernel/av/value.go:821-822 for the canonical constants AssetTypeFile and AssetTypeImage"],"exampleFix":"// before\nvalue.MAsset = []*av.ValueAsset{{Type: \"link\", Content: \"https://example.com\"}}\n// after\nvalue.MAsset = []*av.ValueAsset{{Type: av.AssetTypeFile, Content: \"https://example.com\"}}","handlingStrategy":"validation","validationCode":"func validateMAssetTypes(value *av.Value) error {\n    for _, asset := range value.MAsset {\n        if asset == nil || strings.TrimSpace(asset.Content) == \"\" {\n            continue\n        }\n        if asset.Type != av.AssetTypeFile && asset.Type != av.AssetTypeImage {\n            return fmt.Errorf(\"asset type must be %q or %q, got %q\", av.AssetTypeFile, av.AssetTypeImage, asset.Type)\n        }\n    }\n    return nil\n}","typeGuard":"func isValidAssetType(t string) bool {\n    return t == av.AssetTypeFile || t == av.AssetTypeImage\n}","tryCatchPattern":null,"preventionTips":["Always use the av.AssetTypeFile and av.AssetTypeImage constants rather than string literals","Filter out assets with unrecognized types before constructing the template value","Refer to kernel/av/value.go:821-822 for the canonical asset type constants"],"tags":["attribute-view","validation","asset","new-item-template","go"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}