{"record":{"id":"50448bc4de35f6f1","repo":"siyuan-note/siyuan","slug":"url-value-is-missing","errorCode":null,"errorMessage":"URL value is missing","messagePattern":"URL value is missing","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/av/new_item_template.go","lineNumber":388,"sourceCode":"\t\tif nil == value.Date {\n\t\t\treturn nil, errors.New(\"date value is missing\")\n\t\t}\n\t\tvalue.Text, value.Number, value.MSelect, value.URL, value.Email, value.Phone, value.MAsset, value.Checkbox, value.Relation = nil, nil, nil, nil, nil, nil, nil, nil, nil\n\tcase KeyTypeSelect, KeyTypeMSelect:\n\t\tvar selections []*ValueSelect\n\t\tfor _, selection := range value.MSelect {\n\t\t\tif nil != selection && \"\" != strings.TrimSpace(selection.Content) {\n\t\t\t\tselections = append(selections, selection)\n\t\t\t}\n\t\t}\n\t\tif KeyTypeSelect == key.Type && 1 < len(selections) {\n\t\t\tselections = selections[:1]\n\t\t}\n\t\tvalue.MSelect = selections\n\t\tvalue.Text, value.Number, value.Date, value.URL, value.Email, value.Phone, value.MAsset, value.Checkbox, value.Relation = nil, nil, nil, nil, nil, nil, nil, nil, nil\n\tcase KeyTypeURL:\n\t\tif nil == value.URL {\n\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)","sourceCodeStart":370,"sourceCodeEnd":406,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/av/new_item_template.go#L370-L406","documentation":"For KeyTypeURL values, normalizeNewItemTemplateValue requires a non-nil Value.URL object; otherwise it returns 'URL value is missing'. The normalizer clears every other field, so a URL-typed value without a URL payload is structurally invalid and rejected rather than silently kept.","triggerScenarios":"PruneInvalidNewItemTemplateFieldValues / normalizeNewItemTemplateFieldValues called on a value whose key type is KeyTypeURL but whose Value.URL pointer is nil (URL object missing in the template JSON or zero-value struct).","commonSituations":"Templates authored by hand where only a text string was supplied instead of a URL object; plugins creating new rows programmatically and leaving Value.URL unset after setting Value.Type to url.","solutions":["Supply the URL object, e.g. {\"url\":{\"content\":\"https://example.com\"}}","Rename the value's type to match what was actually provided (e.g. text)","Remove the invalid value before pruning runs","Guard callers with a nil check on Value.URL before invoking normalization"],"exampleFix":"// before\nav.Value{Type: av.KeyTypeURL} // URL nil\n// after\nav.Value{Type: av.KeyTypeURL, URL: &av.ValueURL{Content: \"https://example.com\"}}","handlingStrategy":"validation","validationCode":"if v.Type == av.KeyTypeURL && v.URL == nil {\n    return fmt.Errorf(\"URL value requires a URL object\")\n}","typeGuard":"func hasURL(v *av.Value) bool { return v != nil && v.Type == av.KeyTypeURL && v.URL != nil }","tryCatchPattern":null,"preventionTips":["Set Value.URL.Content, not Value.Text, for url-typed values","Validate template payloads against the value schema before calling pruning APIs","Keep URL assets in mAsset fields, URLs in url fields"],"tags":["attribute-view","validation","nil-value"],"backgroundTag":"null-argument","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"}