{"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/9f775e8a12daef8255556097396f9b2739078892/kernel/av/new_item_template.go#L388-L424","documentation":"MAsset-typed template values may only contain assets of type AssetTypeFile or AssetTypeImage; any other asset type causes normalizeNewItemTemplateValue to fail with 'invalid asset type [%s]'. The check runs per asset inside the MAsset slice before the pruned list is stored.","triggerScenarios":"A value passed to PruneInvalidNewItemTemplateFieldValues / normalizeNewItemTemplateFieldValues whose MAsset slice contains a ValueAsset with Type not equal to file or image (e.g. empty string, or a custom/unknown type).","commonSituations":"Templates hand-edited to reference attachments whose type constant was misspelled; code from another av module writing asset types not covered by the template normalizer.","solutions":["Set the asset Type to \"file\" or \"image\" as appropriate","Remove the offending asset from the MAsset list","Move non-file/image attachments to a supported field type","Validate asset.Type against AssetTypeFile/AssetTypeImage before submitting"],"exampleFix":"// before\nassets := []*av.ValueAsset{{Type: \"attachment\", Content: \"a.pdf\"}}\n// after\nassets := []*av.ValueAsset{{Type: av.AssetTypeFile, Content: \"a.pdf\"}}","handlingStrategy":"validation","validationCode":"for _, a := range v.MAsset {\n    if a.Type != av.AssetTypeFile && a.Type != av.AssetTypeImage {\n        return fmt.Errorf(\"asset type %q not allowed\", a.Type)\n    }\n}","typeGuard":"func validAssetType(a *av.ValueAsset) bool { return a != nil && (a.Type == av.AssetTypeFile || a.Type == av.AssetTypeImage) }","tryCatchPattern":null,"preventionTips":["Use the AssetTypeFile/AssetTypeImage constants, never raw strings","Filter or drop unsupported asset types before submission","Keep asset-producing code in sync with the template normalizer's allowed types"],"tags":["attribute-view","assets","validation"],"backgroundTag":"invalid-enum-value","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"}